Let google help you host the Ajax Library

Source: Internet
Author: User
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
  1. <Script SRC=Http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" Type="Text/JavaScript"></Script>
  2. Or
  3. <Script SRC=Http://www.google.com/jsapi"></Script>
  4. <Script Type="Text/JavaScript">
  5. Google. Load ("jquery", "1.2.6 ");
  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.

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.