Jquery makes it easier and quicker to control page elements, so we don't need to worry too much about browser features when writing JavaScript. However, the more powerful jquery is, the more files it has. During website optimization, we usually optimize the hundreds of K downloads that can be squeezed out by JS, CSS, and image files.
Google is very interesting enough to provide the jquery library. By using the jquery library provided by Google, Google's server and line quality are naturally nothing. This increases the download speed and reduces the number of concurrent connections on your server.
It's easy to use. Just reference the relevant JS files on the Google server on the webpage. However, if you reference multiple JavaScript codes, you need to insert multiple scripts. Google also provides the corresponding method, that is, Google load. We only need to reference a JS file on the page to load the JS library used in real time as needed.
First, add the following line to the page headerCode:
<SCRIPT type = "text/JavaScript" src = "http://www.google.com/jsapi"> </SCRIPT>
Load jquery, which can be used as follows:
Google. Load ("jquery", "1.3.2 ");
In this way, we load the JS library of jquery 1.3.2 from Google's latest CDN image, and then we can write the JS Code normally. However, even Google's CDN images take time to download. What if the browser has explained the following code before the code library is downloaded? We can set to execute JS after loading the JS Library:
Google. setonloadcallback (function () {// code to be executed });
For more information about Google jsapi, see: Google Ajax library API
In addition to jquery, Google also provides APIs for the following JS frameworks/Libraries:
Jquery UI
Prototype
Script. aculo. Us
Mootools