jQuery高效且性能良好 [英] Jquery efficient and good performance

查看:77
本文介绍了jQuery高效且性能良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我始终把效率和性能放在第一位...

I always keep efficiency and performance as the first priority...

所以我在想一个问题...哪个加载速度会更快.

So I have a question in mind...Which one will load faster.

案例1:

放在body标签底部的单个文件中的1000行代码.

A 1000 line code in a single file placed at the bottom of the body tag.

案例2:

相同的1000行代码分为多个单独的文件.

The same 1000 line code divided into separate files like.

文件1-200行.

文件2-200行.

文件3-200行.

文件4-200行.

文件5-200行.

推荐答案

案例1 将更快.

在每个新文件上,浏览器都会向服务器发出请求,因此这需要额外的时间(大约200毫秒).如果您只使用一个文件,则效率更高,因为浏览器只会向服务器发出一个请求.

On every new file, browser will do request to the server so it's additional time (about 200ms). If you are using one single file, it's more efficient, because browser will do only one request to the server.

有关加速网站的更多信息,请参见本文.

More information about speeding up web sites in this article.

这篇关于jQuery高效且性能良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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