how to fallback twitter-bootstrap cdn to local copy

John Wang picture John Wang · Sep 25, 2012 · Viewed 11.6k times · Source

There are many posts about how to fallback a JQuery CDN to a local copy by checking the existance of the global variable JQuery.

My question is , how to do the same to twitter-bootstrap ? Is there a variable defined in bootstrap so that I can check to make sure the CDN is available ?

BTW, I use netdna.bootstrapcdn.com as my bootstrap CDN

Answer

Marcel picture Marcel · Nov 6, 2012

This is what I did and it works fine

<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<script>    $.fn.modal || document.write('<script src="Script/bootstrap.min.js">\x3C/script>')</script>