Smart way to add jquery or other js from Google's cdn - fail over to local copy


/ Published in: JavaScript
Save to your folder(s)

if the Google cdn copy of jquery or what ever fails, use a local copy of the script


Copy this code and paste it in your HTML
  1. <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
  2. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
  3. <script type="text/javascript">!window.jQuery && document.write('<script src="http://www.thiswebsitesdomain/js/jquery.js"><\/script>')</script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.