Return to Snippet

Revision: 61026
at November 23, 2012 01:01 by ahmadassaf


Initial Code
// Anonymous "self-invoking" function
(function() {
    // Load the script
    var script = document.createElement("SCRIPT");
    script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
    script.type = 'text/javascript';
    document.getElementsByTagName("head")[0].appendChild(script);

    // Poll for jQuery to come into existance
    var checkReady = function(callback) {
        if (window.jQuery) {
            callback(jQuery);
        }
        else {
            window.setTimeout(function() { checkReady(callback); }, 100);
        }
    };

    // Start polling...
    checkReady(function($) {
        // Use $ here...
    });
})();

Initial URL


Initial Description
Load jQuery dynamically in a page from Javascript

Initial Title
Load jQuery dynamically from Javascript

Initial Tags


Initial Language
JavaScript