Created
May 14, 2015 15:13
-
-
Save dlfinis/4142434f6668760e0542 to your computer and use it in GitHub Desktop.
Check if exits an jquery script load
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
## One way | |
if(!("jQuery" in window)) { | |
var head = document.getElementsByTagName('head')[0], | |
script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = '/resources/js/lib/jquery-2.1.0.min.js'; | |
head.appendChild(script); | |
} | |
## Second way | |
if (typeof jQuery == 'undefined') { | |
\\do somenthing if not exist | |
} | |
else | |
{ | |
\\do somenthing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment