开发者

jquery install -- copy/paste vs download linked file

When installing jquery from 开发者_如何学Pythonthe website, the files are different when I copy/paste from the browser window vs right clicking and choosing download linked file. Why is this? Which way is right?

(I know they are different because of git diff.)


There is technically no "right" way, but I don't think copy/pasting them into your own Javascript file would be the best route. I'm not sure whether you're pasting it into a Javascript file that has a number of other functions that you have made or whether you're pasting it into its own separate file, but in either case I think right-clicking and choosing download as would be your best bet.

Aside from that I would recommend using a CDN instead of actually hosting the file locally. jQuery is available on a number of CDNs and using one is relatively safe as they are pretty widespread (meaning if the CDN goes down there are going to be a LOT of broken web sites, not just yours). Using a CDN makes it so that you don't have to go download / upload the file to your web server every time there is an update and it also makes it so that some of your visitors may already have the file cached. For instance:

1) Person A visits website A which is also pointing to the CDN version of the latest version of jQuery. They browse that site for a bit

2) Person A visits your website which points to the jQuery CDN version. They do not have to get the file again because the browser notices that both references are the same and therefore loads the file that has been cached.

In doing so you can cut down on your own bandwidth (albeit a minimal amount unless you're talking thousands of visitors a day) and lighten the burden of maintenance on your end as well.

Just my opinion though. Cheers

EDIT

CDN = Content Delivery Network if you didn't already know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜