Posted By

cyberpunkstudio on 02/01/12


Tagged

javascript jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

adrianparr


Grab jQuery library from Google's CDN if failed then pull local version


 / Published in: JavaScript
 

Grab jQuery library from Google's CDN this way its faster, burns Google's bandwidth and not yours. Also users will have this cached if other sites are using it as well.

Downside of course is Google's servers do go down. This script will check if its available on Google's servers otherwise fall back to your local version.

  1. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  2. <script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>

Report this snippet  

You need to login to post a comment.