Posted By

paul66 on 01/27/11


Tagged

html jquery fallback


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

chrisjlee


jQuery loading fallback


 / Published in: HTML
 

A vast majority of sites these days make use of the jQuery JavaScript library. A vast majority also make use of Google’s hosted version of the library for faster loading speed’s, and better cross site caching. However, what if there is ever a problem and jQuery is not loaded from Google? Well here is your backup. What it basically does is check if jQuery is loaded from Google. If not, then we load it locally from our own version of jQuery.

  1. <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  3. <script>!window.jQuery && document.write('<script src="js/jquery-1.4.2.min.js"><\/script>')</script>

Report this snippet  

You need to login to post a comment.