3

Is there some equivalent to jQuery's getScript in Prototype ?

1 Answer 1

5
var head;

var script;

head = $$('head')[0];
if (head)
{
    script = new Element('script', { type: 'text/javascript', src: 'dynamic.js' });
    head.appendChild(script);
}
Sign up to request clarification or add additional context in comments.

3 Comments

Im loading this script after a user interaction, so I dont think inserting in head would execute it, would it ? Anyway, I've used native JS to add this. Hopefully this works in all browsers. var fileref = document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", "domain.com/script.js");
Cool, now is there a onComplete? how can I detect when it finishes loading?
That was 2010, leave these stuff and move to Angular, Backbone etc. Also look at script loading with require.js if you just need to add script modules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.