Skip to content

Instantly share code, notes, and snippets.

@LarryAnomie
Last active December 25, 2015 18:39
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 LarryAnomie/7021683 to your computer and use it in GitHub Desktop.
Save LarryAnomie/7021683 to your computer and use it in GitHub Desktop.
conditionally load JQuery 2 for new browsers
<script>
// set a global version var for cache busting
var CITY_VERSION = "%globals_snippet_77381%.";
yepnope([
{
test: 'querySelector' in document && 'localStorage' in window && 'addEventListener' in window,
yep: {
"jQuery2" : '//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js'
},
nope: {
'jQuery1': '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'
},
callback: {
"jQuery1" : function (url, result, key) {
if (!window.jQuery) {
yepnope('local/jquery.min.js');
}
},
"jQuery2" : function (url, result, key) {
if (!window.jQuery) {
yepnope('local/jquery.min.js');
}
}
}
}, {
// this should download as soon as this line is executed, but won't be executed until after the local jquery is loaded
load : "//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"
}, {
load : "//s1.dev.city.ac.uk/cassrmain/js/%globals_snippet_77381%.cassrmain.js",
callback : function (url, result, key) {
CASS.init();
}
}
]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment