The
AJAX Search API blog was announced yesterday by the
AJAX Libraries API . The bottom line is that Google now allows everyone to use JavaScript frameworks hosted on their servers. The API itself is an easy-to-use mechanism for connecting HTML documents to the most popular JS libraries, including jQuery, prototype, script.aculo.us, MooTools, and dojo. The list is likely to expand.
Connect the necessary library in two ways. The first is trivial, using an HTML script element.
<code> <script src = "http://ajax.googleapis.com/ajax/
libs / prototype / 1.6.0.2 / prototype.js "> </ script> </ code>
')
As it is not difficult to guess, instead of
prototype/1.6.0.2
you can specify the name of any other framework and its version.
The second method is more flexible. Using the special JS method
google.load()
you can specify the version of the library not exactly, but by the first digits.
<code> <script src = "http://www.google.com/jsapi"> </ script>
<script>
google.load ("prototype", "1.6");
// ...
</ script> </ code>
The value “1.6” specified in the example means that the most recent prototype version in the 1.6 branch will be automatically selected. Thus, the AJAX Libraries API can provide auto-update of JS libraries without any changes in the calling script (naturally, such an update is limited to the limits of the desired branch).
The main advantages of using the AL API include the following:
- Keeping scripts on Google somewhat reduces the load on your own web server.
- The speed of loading pages increases due to the transfer of part of requests to another host and the support of gz-compression.
- With massive use of centrally-stored frameworks, the browser cache is used more efficiently. A file uploaded for one web application can be reused when working with another using the same framework. While this is only a potential benefit of the service, but, nevertheless, pleasant.
- In addition, thanks to Google, it is possible to facilitate distributions of web applications using JS frameworks.
Related Links
Crosspost with
paradigm.ru .