Use the Google CDN JQuery Library

Source: Internet
Author: User

CDN stands for Content Delivery Network (CDN. The purpose is to add a new network architecture to the existing Internet to publish website content to the "edge" closest to the user's network ", this allows users to obtain the desired content from the nearest node to solve the problem of Internet congestion and improve the response speed of users accessing the website. Technically, it solves the slow response speed caused by low network bandwidth, large user traffic, and unevenly distributed outlets. For more information, see here: http://code.google.com/p/mydocspace/wiki/CDN

I think you are familiar with the following javascript code.

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

In this way, the jquery library file is loaded through Google's CDN-Content Delivery Network.

However, many friends store jquery library files on the server for loading. Of course, this method is not good for those servers. For details, google jquery is recommended. Speaking of this, some students asked why google jquery library should be loaded? Let me talk about the advantages of using Google to load jquery library files.

  1. Maybe loading jquery from Google is not necessarily faster than your site. However, when a visitor accesses another site that loads google's jquery library to access your website, the browser will detect the jquery library version. The jquery library of the same version points to the google link, the browser will determine that this is the same file, and Google's server will return a 304 (no command to modify the file, that is, the file on the server has not been changed) to reply to a duplicate request, it also commands the browser to cache the file for up to one year. In this way, the jQuery library of the same version does not need to be loaded in the browser cache.
  2. Load google jquery to reduce server requests.
  3. It's just friends who use space outside China. Let me take this for example. The server is very unstable, sometimes other content is loaded, but the JS file cannot be loaded (this refers to loading the JS file on the server ).

Although there are many advantages to loading google jquery, it is well known that tianchao is very disgusted with google's stuff and google often cannot access it. If we load google jquery, will it fail?

The following is a method for loading google jquery based on conditions.

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

Put the above Code in

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.