Sign up to create your own snipts, or login.

Public snipts » pdokas's snipts » Load jQuery even if the Google CDN is down

posted on Oct 07, 2009 at 6:22 p.m. EDT in 
  • <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>
    

    copy | embed

0 Comments

Sign up, or login to leave a comment.