Reasons for using the Google jquery Library File

Source: Internet
Author: User

Reasons for using the Google jquery Library File

Recently, many websites that reference jquery files use Google libraries; such as <script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script> (recently developed to version 1.7.1, so fast, two days ago, I saw a buddy using 1.2.6 with emotion ....)

Loading jquery like above uses Google's CDN-Content Delivery Network to load jquery library files on your website. Some may ask why Google's jquery library file should be loaded? (PS: do we usually load jquery library files on our servers ?). Haha ~~ I have always thought about loading jquery files on my own server.
Let me talk about the advantages of using Google to load jquery library files.

1. Increase the Simultaneous loading speed of webpages
To avoid service overload, the browser limits the number of simultaneous connections. Depending on different browsers, this limit may be limited to only two of each data center.
Use Google's AJAX content service network to respond to your website, so that more services can be performed on your local server at the same time.

2. Reduce the waiting time
Everyone should be similar. They are feeling the strength of jquery and the strength of jquery's team ~ Now the latest jquery version is 1.7.1, but it is quite uncomfortable that even the mini compressed code has 83.2KB. But I don't know if you have read it on the official homepage.

CDN-Content Delivery Network (Content Delivery Network) refers to the distribution of some of your static Content through a variety of service channels. When a user's browser submits a request for a link to these files, they will automatically download the most recent available files on the network.
For this reason, any user using your service downloads the JQuery library from Google faster than downloading it from your own server. In fact, there are many CDN services comparable to Google's, but it is difficult for them to surpass Google's free service advantages. This benefit is enough to determine the problem, but this is only part of it.

3. Better caching
The biggest benefit of using the Google AJAX library content publishing service is that your users do not need to download jQuery. no matter how powerful your cache is, if you use your server to provide jQuery, your users must download it at least once, A user is likely to download many completely identical jQuery files in the cache area of their browsers. min. but when they visit your website for the first time, these copied versions will be ignored.
On the other hand, when the browser detects a link to Google in the same version, it will know that this is the download of the same file, not only does Google's server return a 304 message (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.
This means that even if some people access hundreds of jQuery websites using Google services, they only need to download them once.

However, it seems that tianchao has been a little disgusted with Google's things recently. Just like Google was angry and ran out of Hong Kong before, Sometimes Google's things could not be opened, will it fail to load the jquery library files one day? Haha ~~ Everything is possible ~ It doesn't matter. Here there are 10 thousand full methods:

<Script type = text/javascript src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”> </script>

<Script>! Window. jQuery & document. write ('<script src = "jquery-1.7.1.min.js"> <\/script>'); </script>

Put the above Code in the header of your html code. The significance is as follows: first, load Google's jquery library file. If the file is not loaded successfully, you have to load the jquery library file on your server.


Author: snow float outside the sky

Related Article

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.