Posted By

hced on 12/17/10


http javascript js google script jquery load api https Linking CDN libs bestpractice ajaxapi

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Proper way of loading jQuery from Google's CDN with fallback to local lib if necessary

 / Published in: HTML


Proper way of loading libs such as jQuery from Google's CDN. Place these JavaScripts at the bottom for fast page loading. To target different versions, you can be more specific if you want; eg. /1.4/ or even /1.4.4/.

(NOTE: you may either use http:// or https:// depending on your needs. Both will work.)

  1. <!-- Load jQuery from Google's CDN -->
  2. <script src="//"></script>
  3. <!-- Fall back to local lib if loading from Google's CDN fails -->
  4. <script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.4.js"%3E%3C/script%3E'))</script>

Report this snippet  

You need to login to post a comment.