JQuery: How do I perform a callback on JQuery once it's loaded?

Posted by Teddyk on Stack Overflow See other posts from Stack Overflow or by Teddyk
Published on 2010-05-11T19:02:13Z Indexed on 2010/05/11 19:14 UTC
Read the original article Hit count: 192

Filed under:
|
|

I'm downloading JQuery asynchronously:

function addScript(url) {
    var script = document.createElement('script');
    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
}
addScript('jquery.js');

// non-jquery code ...

// jquery specific code like: $()...

As such - how do I call my JQuery specific code once JQuery is loaded (because since I'm downloading my JavaScript asynch - it's not blocking, which is good, but is trying to execute my JQuery specific code before JQuery has been loaded).

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about callback