Skip to content

Instantly share code, notes, and snippets.

@PandaEox
Created August 1, 2014 05:00
Show Gist options
  • Save PandaEox/a04d71a4dfd728ab90c3 to your computer and use it in GitHub Desktop.
Save PandaEox/a04d71a4dfd728ab90c3 to your computer and use it in GitHub Desktop.

Revisions

  1. PandaEox created this gist Aug 1, 2014.
    23 changes: 23 additions & 0 deletions dynamic.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // 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...
    });
    })();