Skip to content

Instantly share code, notes, and snippets.

@shinnn
Created June 10, 2013 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shinnn/5747814 to your computer and use it in GitHub Desktop.
Save shinnn/5747814 to your computer and use it in GitHub Desktop.
Loading CDN-hosted jQuery with triple fallbacks in Jade template Engine
mixin loadJQuery(version)
script(src='https://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js')
- var jQueryFallbacks = [];
- jQueryFallbacks[0] = 'http://code.jquery.com/jquery-' + version + '.min.js';
- jQueryFallbacks[1] = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' + version + '.min.js';
- jQueryFallbacks[2] = 'js/jquery' + (version.charAt(0) === '1'? '1': '') +'.js';
each url in jQueryFallbacks
script.
window.jQuery || document.write('<script src=#{url}><\/script>');
//if lt IE 9
mixin loadJQuery('1.10.1')
//if gte IE 9
<!-->
mixin loadJQuery('2.0.2')
<!--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment