Google Ajax libraries API accelerates loading of your JS scripts

Source: Internet
Author: User

Google has spent a lot of time making network applications faster. Calling js scripts is one of the features that we often use. Too many script calls often slows down web pages.

Google seems to be trying to solve this problem, making it faster and easier for everyone to use the Javascript framework. To this end, Google has provided a new item called Ajax Libraries API.

The idea of Ajax Libraries API is very simple: it runs Javascript on Google servers and uses Google's quick distribution server to compress Gzip when necessary. More importantly, the cache mechanism is used to improve the loading of multiple users at the same time.

Using AJAX Libraries APIs has the following advantages:

  • Developers do not need to consider how to set the cache mechanism. Google will prepare everything for you.
  • If another application uses the same Javascript framework, the client does not need to obtain the script again because it is already cached on the user's machine.
  • You do not need to consider the network environment and traffic restrictions
AJAX Libraries API currently supports the following JS frameworks
  • JQuery
  • JQuery UI
  • Prototype
  • Script_aculo_us
  • MooTools
  • Dojo
  • SWFObject
  • Yahoo! User Interface Library (YUI)
Ajax Libraries API call Method 1:

For example, load Prototype 1.6.0.2.

<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>

Ajax Libraries API call Method 2:

 

 

<Script src = "http://www.google.com/jsapi"> </script>
<Script>
// Load jQuery
Google. load ("jquery", "1 ");
// On page load complete, fire off a jQuery json-p query
// Against Google web search
Google. setOnLoadCallback (function (){
$. GetJSON ("http://ajax.googleapis.com/ajax/services/search/web? Q = google &; v = 1.0 &; callback =? ",
// On search completion, process the results
Function (data ){
If (data. responseDate. results &&
Data. responseDate. results. length> 0 ){
RenderResults (data. responseDate. results );
}
});
});
</Script>

 

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.