A little jQuery redundancy

It’s kind of absurd to think that one of our sites would be up while Google’s Libraries API is down, but there is a real possibility that the google domain name could be blocked in certain countries and in certain circumstances. So just to be safe, here’s a quick little snippet to make sure it’s loaded either way. Note, this assumes you have jQuery on your webserver.

1
2
3
4
5
6
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
    document.write(unescape("%3Cscript src='/js/jquery1.5.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>

Leave a Reply