ajax触发load
The problem: loads of websites around the internet using the exact same JavaScript file. The file is a whopping 100KB in size. Since this same file resides on each website's server, the file is downloaded and cached for each individual website. Lots of load time for same file.
问题是:使用完全相同JavaScript文件在Internet上加载大量网站。 该文件的大小高达100KB。 由于此文件位于每个网站的服务器上,因此将为每个网站下载并缓存该文件。 同一文件的加载时间很多。
The answer: Google AJAX Libraries APIs. Google hosts these frequently used files, including the newest versions (and legacy versions) of jQuery MooTools, YUI, Dojo, Prototype, and more. Why use Google's AJAX Libraries API? Benefits include:
答案: Google AJAX库API 。 Google托管这些常用文件,包括jQuery MooTools,YUI,Dojo,Prototype等的最新版本(和旧版本)。 为什么要使用Google的AJAX库API? 好处包括:
- Google's servers can serve the file faster than your shared hosting server. Google的服务器可以比共享的托管服务器更快地提供文件。
- Since the file is always being pulled from the same place, the more sites that use that file, the more likely that file is already in the user's cache. Thus, your website loads faster. 由于总是从同一位置提取文件,因此使用该文件的站点越多,该文件已在用户缓存中的可能性就越大。 因此,您的网站加载速度更快。
- You save bandwidth. 您可以节省带宽。
Here's how you implement google.load().
这是实现google.load()的方法 。
JavaScript (The JavaScript)
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
//get the latest moo
google.load('mootools', '1.2.1');
//other examples
google.load('jquery', '1.3.1');
google.load('jqueryui', '1.5.3');
google.load('prototype', '1.6.0.3');
google.load('scriptaculous', '1.8.2');
google.load('mootools', '1.2.1');
google.load('dojo', '1.2.3');
google.load('swfobject', '2.1');
google.load('yui', '2.6.0');
That's all there is to it. Pass Google the library and version you desire and Google does the rest.
这里的所有都是它的。 将所需的库和版本传递给Google,其余的由Google完成。
ajax触发load