Skip to content

Instantly share code, notes, and snippets.

@brainix
Last active December 11, 2015 21:28
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 brainix/4662675 to your computer and use it in GitHub Desktop.
Save brainix/4662675 to your computer and use it in GitHub Desktop.
Haml use jQuery 1.x for old IE, 2.x for all other browsers
- jquery_1x = 'jquery-1.11.0-beta2.min.js'
- jquery_2x = 'jquery-2.1.0-beta2.min.js'
/[if lt IE 9]
-# The user is on an ancient browser. Load jQuery 1.x from the CDN.
%script{src: "http://code.jquery.com/#{jquery_1x}"}
-# If loading jQuery from the CDN fails, then load our local copy.
:javascript
window.jQuery || document.write(
'<script src="#{uri('/javascripts/vendor/' << jquery_1x)}">' +
'<\/script>'
);
= surround '<!--[if gte IE 9]><!-->', '<!--[endif]-->' do
-# The user is on a modern browser. Load jQuery 2.x from the CDN.
%script{src: "http://code.jquery.com/#{jquery_2x}"}
-# If loading jQuery from the CDN fails, then load our local copy.
:javascript
window.jQuery || document.write(
'<script src="#{uri('/javascripts/vendor/' << jquery_2x)}">' +
'<\/script>'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment