Loading jQuery from Google with a local backup on fail

Just this morning the internet connection got all flaky on me and loading jQuery from Google’s CDN started taking a long time.  Because of this, things like my menu, a slider, some graphing applications and a few other things started taking FOREVER to load.  Chrome kept telling me it was waiting on the https address of jQuery.  This made me think.  “What if, 5 years down the road, jQuery 1.8.1 just isn’t available anymore?”  So, I decided I better make sure there’s some redundancy in my scripts.

So, if you need to load jQuery, or anything really, and you prefer to use a central repository, but you want to have a local backup, just in case, do this…




Oh, and if you need to load jQuery UI too, it’s a little different.


These examples obviously use specific versions of the scripts. If you are (very likely) wanting to use different versions, just substitute them. Duh, right?

2 thoughts on “Loading jQuery from Google with a local backup on fail

    • Matt Danskine says:

      Well, it’s always best to load “stuff” like jQuery from a CDN. Much bigger, better, faster servers and you never know where someone is looking at your website from. Could be the CDN is closer. There can be issues getting the scripts from the CDN though, so it’s a good idea to have a failsafe local version. Make sense?

Leave a Reply

Your email address will not be published. Required fields are marked *