Skip to content

Instantly share code, notes, and snippets.

@mikebucks
Created April 2, 2012 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebucks/2284949 to your computer and use it in GitHub Desktop.
Save mikebucks/2284949 to your computer and use it in GitHub Desktop.
Check for jQuery and add it if needed
var hasjQuery = false;
jQueryCheck = function() {
if (! window.jQuery) {
if (! hasjQuery) {
hasjQuery = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
document.getElementsByTagName('body')[0].appendChild(script);
}
setTimeout('jQueryCheck()', 50);
} else {
$(function() {
//do $ stuff
});
}
}
jQueryCheck();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment