Load jQuery even if the Google CDN is down

[javascript]
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
// Ensure that jQuery is installed even if the Google CDN is down.
if (typeof jQuery === "undefined") {
var script = document.createElement(‘script’);
var attr = document.createAttribute(‘type’);
attr.nodeValue = ‘text/javascript’;
script.setAttributeNode(attr);
attr = document.createAttribute(‘src’);
attr.nodeValue = ‘/scripts/jquery-1.3.2.min.js’;
script.setAttributeNode(attr);
document.getElementsByTagName(‘head’)[0].appendChild(script);
}
</script>
[/javascript]

Leave a Reply