Skip to content

Instantly share code, notes, and snippets.

@rodolfo42
Created July 3, 2014 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodolfo42/f43053f2d70fd83f424e to your computer and use it in GitHub Desktop.
Save rodolfo42/f43053f2d70fd83f424e to your computer and use it in GitHub Desktop.
Code to simulate registering onload callbacks with $( <function> ) but before jQuery is included in the page
window.$ = (function () {
var cbs = [];
return function (callback) {
cbs.push(callback);
window.onload = function () {
while( !window.jQuery );
cbs.map(function (c) { c(); });
};
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment