Skip to content

Instantly share code, notes, and snippets.

@dlfinis
Created May 14, 2015 15:13
Show Gist options
  • Save dlfinis/4142434f6668760e0542 to your computer and use it in GitHub Desktop.
Save dlfinis/4142434f6668760e0542 to your computer and use it in GitHub Desktop.
Check if exits an jquery script load
## 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