javascript - jQuery/JavaScript - 有很多小的 .js 文件时的性能问题?

标签 javascript jquery performance include jscompress

我有一个站点,其中包含大量引用的 .js 文件;这些都是相当小的文件,但我想将我的方法按主题/功能分开。

是将所有方法保存在一个 .js 文件中更好,还是拥有许多(~ 20 - 30)个小文件都只包含一些行是否没有问题?

最佳答案

在开发时一定要将它们分开,但您应该考虑将它们捆绑到一个文件中以进行生产。

sitepoint.com 上有很好的讨论

For each of these files, an HTTP request is sent to the server, and then the browser awaits a response before requesting the next file. Limits (or limitations) of the browser generally prevent parallel downloads. This means that for each file, you wait for the request to reach the server, the server to process the request, and the reply (including the file content itself) to reach you. Put end to end, a few of these can make a big difference to page load times.

关于javascript - jQuery/JavaScript - 有很多小的 .js 文件时的性能问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/316944/

相关文章:

c++ - 这是多重继承的好用法吗?

java - C中是否有与指针函数类似的java ByteBuffer函数

javascript - 拦截javascript中对象的方法

javascript - jqplot从表中设置数据系列

javascript - toDateString() 减少我的日期

ajax - Jquery ajaxSubmit 也执行常规表单提交

javascript - 在 Google Apps 脚本中的多行上写入单个值

javascript - 如何将多种数据/数据类型发布到 php?

javascript - 排名数字数组值

python - 在线性时间内获取列表中第二大的数字