Practical Web Programming

Wednesday, November 06, 2013

How to Load Your Own jQuery Library When CDN is Down

It's always a good practice to load libraries like jQuery your web applications from CDN (Content Delivery Network). But sometimes (though rare) CDN goes down. The code below makes that you have jQuery loaded in events like this.


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">if (typeof jQuery == 'undefined') {  document.write(unescape("%3Cscript src='Scripts/jquery.2.0.0.min.js' type='text/javascript'%3E%3C/script%3E"));
}</script>

0 comments:

Recent Post