Using the jquery library provided by Google CDN Services

Source: Internet
Author: User
Tags jquery library

JQuery, let us control the page elements more convenient and fast, let us write JS when we do not need to think too much of the browser characteristics. But the more powerful the jquery function, the greater its own file. When doing site optimization, usually through the optimization of JS, CSS and picture files can squeeze out the hundreds of k size of the download.

Google is very interesting, it provides a jquery library, by using Google's jquery library, Google's server and line quality that is not a cinch. This increases the download speed and reduces the number of concurrent connections for your server.

It is also very simple to use, directly in the Web page to reference the relevant JS file on Google server can be. However, if you refer to more than one JS, you should insert multiple script pieces. Google also provides the appropriate solution, that is, Google load. We only need to quote a JS file in the page, we can load the JS library in real-time according to the need.

First, add the following line of code in the header section:
< script type= "Text/javascript" src= "Http://" ></script>

Loading jquery, you can use this:
Google.load ("jquery", "1.3.2");

In this way we will be from Google's recent CDN image loaded with the jquery 1.3.2 version of the JS library, then you can write the normal JS code. However, even Google's CDN image, download is after all, it takes time, in case the code base has not been downloaded and the browser has explained the following code how to do. We can set the JS library after loading to start the implementation of JS:
Google.setonloadcallback (function () {//code to be executed});
For more information about Google Jsapi's introduction and documentation, refer to: Google AJAX Library API

In addition to Jquery,google, it provides the following JS Framework/Library APIs:
JQuery UI

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: 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.