How to “Detect” If Your CDN is Down And Load a Script Locally As Backup

I’m sure this has been around for a while now, but I just stumbled upon it and found it interesting:

...
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
...

Basically, this does a check to see if jQuery has loaded properly from the CDN and, if it hasn’t, it tries to load it locally.