3 ms·
Possibly a good time for a reminder, folks: It's worth checking that if you're hotlinking to jQuery, it's the Google Hosted Libraries version.[1] It looks like
by dylanpyle 14y ago
Possibly a good time for a reminder, folks: It's worth checking that if you're hotlinking to jQuery, it's the Google Hosted Libraries version.[1]
It looks like code.jquery.com survived whatever the present situation is (otherwise a big chunk of the 'net would be finding out right about now), but it's been made clear for a while [2] that use of the code.jquery.com/* URLs isn't encouraged.
[1]: https://developers.google.com/speed/libraries/devguide#jquery https://developers.google.com/speed/libraries/devguide#jquer...
[2]: http://blog.jquery.com/2009/08/20/codejquerycom-redirected-to-google-ajax-apis/ http://blog.jquery.com/2009/08/20/codejquerycom-redirected-t...
- Jakob 14y agoOr, much better, have a local fallback: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="/js/libs/jquery.1.7.2.min.js"><\/script>')</script>
- dylanpyle 14y agoYep, should have mentioned this, definitely a sensible idea - I believe this specific snippet is taken from HTML5 boilerplate. Google is blocked in some countries!
- degenerate 14y agoI didn't know a fallback could be so simple. Thank you x 3 (the number of scripts I remotely load)
- akirk 14y agoThis is especially valid as the Google server sends a far-future expires header (see below), so as soon as the browser has the file in its cache it won't even try to contact the Google server for a new version of the file. So even if Google's servers go down, the browser will still use its locally available file (even without a possible delay, when waiting for a timeout). $ curl -I ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js HTTP/1.1 200 OK [...] Expires: Sat, 07 Dec 2013 05:29:17 GMT [...]