jQuery loading fallback


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

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.