I have been using the following code for loading JQuery in all of my projects. I grabbed it from http://html5boilerplate.com/. There is extensive disussion of this technique here.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-1.7.1.min.js"><\/script>');</script>
This code works great and seems pretty darn quick once I've put it up on the interwebs, but when I open my .html
file locally it takes ~10 seconds per refresh. Generally I get fed up and alter the code as follows:
<!-- uncomment when going live
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-1.7.1.min.js"><\/script>');</script>-->
<!-- remove following line when going live -->
<script src="jquery-1.7.1.min.js"></script>
Am I missing something obvious here? I feel like I should not be getting the super-slow loading times, but it does resolve itself when comment out those lines.