Created
April 2, 2012 16:48
-
-
Save mikebucks/2284949 to your computer and use it in GitHub Desktop.
Check for jQuery and add it if needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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