Skip to content

Instantly share code, notes, and snippets.

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 rowild/b3d94cbdc7235e8b982b to your computer and use it in GitHub Desktop.
Save rowild/b3d94cbdc7235e8b982b to your computer and use it in GitHub Desktop.
Include jQuery and Modernizr from a CDN and add local fallbacks in case the CDN fails. Versions written in HTML and HAML.
HTML
=====
<script type='text/javascript'>
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
</script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js' type='text/javascript'></script>
<script type='text/javascript'>
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
</script>
HAML
=====
%script(type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")
:javascript
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
%script(type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js")
:javascript
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment