Load jQuery even if the Google CDN is down

2014-09-21 • Plugins • Views: 1674

[php]
<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>
[/php]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Shares