链接到jQuery文件的最佳方式 [英] Best way to link to jQuery files

查看:78
本文介绍了链接到jQuery文件的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就站点性能/速度而言,链接到jquery是否更好,如下所示:

Is it better, in terms of site performance/speed, to link out to jquery, like this:

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

或者将文件放在服务器上并从那里链接到它们,如下所示:

or to put the files on the server and link to them from there instead, like this:

<script src="js/jquery-1.9.1.js"></script>


推荐答案

这取决于谁拥有更快的服务器,对吧? :)

It depends who has the faster server, right? :)

code.jquery.com 有一些优点:


  1. 这很常见。如果用户去过使用该文件的其他网站,则可能已经缓存了该文件。

  1. It's very common. Users are likely to already have that file cached if they've been to another site that uses that file.

可能在地理位置上负载均衡。对于远离您的Web服务器的用户来说,它可以加载得更快。

It's probably geographically load balanced. It could load faster for users who are far away from your web server.

这篇关于链接到jQuery文件的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆