Last active
December 11, 2015 21:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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