Created
December 14, 2011 18:15
-
-
Save icantrap/1477782 to your computer and use it in GitHub Desktop.
Load jquery from Google CDN. Backup to hosted version, if CDN fails
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
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
if(typeof jQuery=="undefined"){ | |
document.write(unescape("%3Cscript src='/js/jquery-1.7.1.min.js' type='text/javascript'%3E%3C/script%3E")); | |
} | |
</script> |
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
<%# In your Ruby: @environment = ENV['RACK_ENV'] %> | |
<% if @environment == 'development' %> | |
<script src="/js/jquery-1.7.1.min.js" type="text/javascript"></script> | |
<% else %> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
if(typeof jQuery=="undefined"){ | |
document.write(unescape("%3Cscript src='/js/jquery-1.7.1.min.js' type='text/javascript'%3E%3C/script%3E")); | |
} | |
</script> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
index.html
has what you want for static HTML. If you're using a framework, then you could also conditionally use a locally hosted version if you're in development environment. For Sinatra, you can check the RACK_ENV environment variable. Seeindex.html.erb
.