Google Hosted Libraries – jQuery

So I tend to do put this line of code when I’m builing a website out of a bad habit:


<script type="text/javascript" src="js/jquery.min.js"></script>

 

That’s where I get lazy as a developer.  Most of you know that JQuery is fucking awesome.  My friend Alex, who is a senior front end developer with over 20 years of experience works over in Bellevue (Snobvue), and he prefers JQuery over javasceript for everything.  As you know, Google offers a lot of sweet Hosted Libraries that let you use JQuery directly from Google’s network of datacenters. It has advantages over hosting jQuery on your server, it decreses latency so your page should be faster and the caching is a lot better.

Google also offers JQuery UI too for all those hardcore devs: hosts full jQuery UI themes on the AJAX APIs CDN.

 

 <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

At any rate, you want to put the code above here in your HTML5.  If you want to be extra safe. Let’s do the fall back, create a copy of the newest minimized version of JQuery and add this code below in case shit hits the fan.  Sorry, this code doesn’t work for older versions of internet explorer… cheers!!!!


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

 

Share on FacebookShare on Google+Pin on PinterestShare on RedditTweet about this on TwitterShare on TumblrShare on LinkedInEmail this to someonePrint this page

Leave a Reply