Google has launched some library hosting services very early. Visitors can load these libraries from Google's servers to save server bandwidth. In addition, if a visitor has visited a website that has the same libraries loaded, the website will be cached without further access.
The following are currently hosted libraries:
Reference:
Jquery
Jquery UI
Prototype
Script_aculo_us
Mootools
Dojo
Swfobjectnew!
Yahoo! User Interface library (Yui) New!
If you do not like English, you can take a brief Chinese introduction.
To put it simply, you can use the following two methods to load jquery 1.2.6:
The XHTML code:
Normal browsing
CopyCode
Print Code
AboutProgram
- <Script SRC=Http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" Type="Text/JavaScript"></Script>
-
- Or
- <Script SRC=Http://www.google.com/jsapi"></Script>
-
- <Script Type="Text/JavaScript">
-
- Google. Load ("jquery", "1.2.6 ");
-
- </Script>
<SCRIPT src = "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type = "text/JavaScript"> </SCRIPT> or <SCRIPT src = "http://www.google.com/jsapi"> </SCRIPT> <SCRIPT type = "text/JavaScript "> Google. load ("jquery", "1.2.6"); </SCRIPT>
Google recommends the latter. I have a rough look at http://www.google.com/jsapi. this javascriptcode uses CDN (content delivery network) to send data to the client, and is lazy loading, which is faster than the former in theory. However, it seems that there are many users in the first method, so the client may have been cached and no download is required, but the response speed is different.
In addition, some parameters include the uncompressed: True parameter. For more information, see.
If you need an SSL link, you can change HTTP to HTTPS to avoid mixed content warnings.
Finally, pay special attention to the fact that to use the code of this library, it must be completed after the library is loaded.
The simplest way is to close Google. Load with </SCRIPT>, and put the code to be executed in the next script.
In addition, you can set Google. setonloadcallback (the function to be run), so that after all the load ends, the function to be run will be automatically called.
For details, see the Google Ajax APIs document.