ajax触发load_google.load():利用Google的AJAX库API

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完成。

翻译自: https://davidwalsh.name/google-load

ajax触发load

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值