Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery backup alternative

Using the below line of code, like most websites do I wonder, is it possible to have a backup alternative for this? For example, if googleapis.com~ is down, use this other script src instead?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

Thanks in advance,

Anders

like image 980
Anders Avatar asked Dec 23 '10 07:12

Anders


1 Answers

Try something like this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>

<script>if(typeof jQuery=="undefined"){document.write(unescape("%3Cscript src='/Scripts/jquery-1.4.3.min.js' type='text/javascript'%3E%3C/script%3E"));}</script>
like image 60
Johnny Oshika Avatar answered Oct 23 '22 22:10

Johnny Oshika