Created
January 10, 2012 20:24
-
-
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.
This file contains hidden or 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
<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