如何找到js的哪个部分导致页面变慢
您好,我的页面在本地服务器上花费了大约 9 秒,在远程服务器上花费了大约 20 秒,我确定问题出在 js 中,但我找不到导致速度变慢的原因,您能帮我找到解决方案或任何工具吗找出问题所在?
hi my page is taking about 9s on local server and about 20s on remote server, i am sure that the problem is in js, but i can't find what makes it slow, can you please help me find a solution or any tool to hunt the problem down?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
现在所有现代主流浏览器都内置了 js 分析。
Firebug & Chrome 都有很好的客户端脚本分析工具,他们还有 http 流量监视器,也可以帮助您诊断问题。 IE 也有一个。
以下是 Firebug 分析器的实际应用示例
[编辑]在 Chrome 中,按 Ctrl+Shift+J 打开 JavaScript 配置文件页面。
All the modern major browsers have js profiling builtin now.
Firebug & Chrome both have good client script profiling tools, also they have http traffic monitors which may also help you diagnose the issue. IE also has one.
Here is an example of the firebug profiler in action
[EDIT]In Chrome, press Ctrl+Shift+J to open the JavaScript profile page.
内置或添加分析工具的替代方案(我想说的首选方式):使用计时器。
我已经编写了这个:
您还可以使用包装函数来计时函数的执行时间。像这样的东西:
Alternative to built-in or add on profiling tools (the preferred way I'd say): use a timer.
I've cooked up this one:
You can also use a wrapper function to time the execution time of a function. Something like:
我将添加 Web Developer 1.1.8 为 Firefox 添加 < a href="http://getfirebug.com/javascript" rel="nofollow">Firebug & Chrome
有关更多详细信息,请查看此内容链接
问候
Wazzy
i will add Web developer 1.1.8 Add on for Firefox with Firebug & Chrome
For more details have a look on this link
with regards
Wazzy
您可以将 YSlow 用于 Firebug。从 YSlow 页面:
You can use YSlow for Firebug. From the YSlow page: