2

Is there a simple way to include a remote js file on the fly (in an onclick function)?

The "verify" onclick event for our ssl site seal requires a code include from the vendor. Trouble is, it slows loads times. So I extracted the function from their js and hosted it locally - but they change the request params from time to time so I have to manually edit the js.

It would be nicer if I could just include the remote file when someone clicks the site seal.

TIA.

1

2 Answers 2

3

If you are using jQuery you can use $.getScript

Description: Load a JavaScript file from the server using a GET HTTP request, then execute it.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks but i want to use as little js as possible and don't want to load up any other libraries such as moo tools or jquery.
So just look at Felix Kling comment : stackoverflow.com/questions/5235321/…
2

You can use the createElement() and add it to the DOM. Please see the below document.

http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.