Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Created January 10, 2012 20:24
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 benjamincharity/1590976 to your computer and use it in GitHub Desktop.
Save benjamincharity/1590976 to your computer and use it in GitHub Desktop.
Load jQuery 1.7.1 from the CDN. If it loads put it into noConflict mode. If it doesn't, load the local copy. Keep checking until the local copy loads and put that into noConflict mode.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min1.js"></script>
<script>
var $$;
// If 1.7.1 is loaded, put it into noConflict mode
if(window.jQuery().jquery = '1.7.1') {
$$ = $.noConflict(true);
} else {
// If it is not loaded, load the local version
document.write("<script src='/js/jquery-1.7.1.js'>\x3C/script>");
// Keep checking until it is loaded
var intervalID = window.setInterval(function() {
// If it is loaded, put it into noConflict mode and clear the interval
if(window.jQuery().jquery == '1.7.1') {
$$ = $.noConflict(true);
window.clearInterval(intervalID);
} else {
// keep trying
}
}, 1000);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment