Use Google's CDN jquery library

Source: Internet
Author: User
Tags jquery library

The full name of the CDN is the Content Delivery network, which is the contents distribution networks. The goal is to add a new layer of network architecture to the existing Internet, publish the content of the site to the "Edge" of the network closest to the user, so that users can get the content they need, solve the congestion on the Internet, and increase the responsiveness of users to the site. The problem of the slow response speed of the user visiting website caused by the small network bandwidth, the large number of users, and the uneven distribution of dot is comprehensively solved technically. For more information see here: Http://code.google.com/p/mydocspace/wiki/CDN

I think we are not unfamiliar with the JavaScript like the one below.

1 <script type="text/javascript"src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>

The above is to load the jquery library file via Google's cdn-content Delivery network (content distribution networks).

But there are a lot of friends who put the jquery library files on the server to load, of course, this method for those server stability is very good to say nothing. If you're looking for details, it's recommended to load Google jquery. Speaking of some of the students here will ask why the bias to load Google jquery library it? Let me talk to you about the benefits of using Google to load jquery library files.

    1. Maybe loading jquery from Google is not necessarily faster than your site. But when visitors visit other Google jquery library sites to visit your site, the browser detects the jquery library version, and the same version of the jquery library points to Google's link, which the browser will judge as a file. And Google's server will return a 304 (no need to modify the file instructions, that is, the file on the server has not changed) to reply to a duplicate request, and will command the browser to cache the file for up to a year. In this way, the same version of the jquery library exists in the browser's cache without loading.
    2. Load Google jquery to reduce server requests.
    3. Is the use of foreign space friends, take me to this, the server is very unstable, and sometimes other content is loaded but JS file is not loaded (this refers to loading the server above the JS file).

Google jquery to load the benefits of a lot, but it is known that the celestial world is very offensive to Google, Google often can not access, if we load Google jquery does not fail it?

Let me tell you a way to load Google jquery based on conditions.

1 <script type="text/javascript"src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
2 <script>!window.jQuery && document.write(‘<script src="/js/jquery-1.3.2.min.js"></script>‘);</script>

Put the above code in the

Use Google's CDN jquery library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.