Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benefits vs. Pitfalls of hosting jQuery locally [closed]

We're currently pulling jQuery and jQueryUI (and jQueryUI CSS) libraries from the google CDN. I like this because I can call google.load("jquery", "1");
and the latest jQuery 1.x.x will be used.

Now I am to pull the libraries locally because of security.

I'm happy to pull them locally but I'm wondering what are some of the other benefits and pitfalls to watch out for?

like image 648
orolo Avatar asked Sep 30 '10 15:09

orolo


People also ask

Is it better to download jQuery or use a CDN?

jQuery CDN generates functioning code that works in various browsers in a shorter time. On the other hand, Web developers require the jQuery download file to parse the library. Raw JavaScript may be faster for some processes, but the advantages of jQuery UI CDN outweigh the disadvantages.

What are the advantages of using CDN in jQuery?

The advantages of using jQuery CDN are as follows: Decreasing the load on your website since the jQuery file will be loaded from a CDN and not from your website. The CDN will reduce the load on your website by loading the data from CDN and not directly from the website.


1 Answers

I always use the CDN (Content Delivery Network) from Google. But just in case it's offline:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script>!window.jQuery && document.write('<script src="jquery-1.4.2.min.js"><\/script>')</script> 

Grab Google CDN's jQuery and fallback to local if necessary

Edit: If you don't need to support IE6 and your site has partial https usage you can remove the http as well:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
like image 114
Xaver Avatar answered Oct 12 '22 00:10

Xaver