Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjamincharity/1571577 to your computer and use it in GitHub Desktop.
Save benjamincharity/1571577 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