响应和页面加载之间的重 Javascript 页面间隙为 15 秒
我有一个页面(A),这是一个繁重的 javascript 页面,当我离开此页面转到页面 B 时,需要很长时间。当我从另一个页面转到页面 B 时,速度非常快。所以它与页面 A 以及可能与它的 javascript 有关。
当我从 IE 9 中的开发人员工具运行网络分析器时,它显示响应和 DomContentLoaded(事件)之间有约 15 秒的间隙。
页面 A 包含大量 JavaScript,因为它运行 Xopus 编辑器(一种富文本 XML 编辑器)。
有人知道我可以做些什么来分析发生的情况的差距,或者我可以做些什么来使页面 A 卸载得更快。
I have a page (A) which is a heavy javascript page, when I leave this page to go to page B it takes a long time. When I go to page B from a different page it is really fast. So it has something to do with page A and probably its javascript.
When I run the network profiler from the developer tools in IE 9 it shows a gap of ~15 seconds between the response and the DomContentLoaded(event).
Page A is heavy with javascript because it runs the Xopus Editor, a rich text XML editor.
Does anybody have any ideas on what I could do to either analyse the gap as to what happens or what I could do to make Page A unload faster.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个可能性不大,因为大约有一千一百处错误,但它可能是一个开始的地方。将此脚本标记作为最后一个添加到您的页面中:
此代码尝试强制卸载页面上加载的每个 JavaScript 文件,并报告删除它们所需的时间(以毫秒为单位)。方便时触发此操作,即在卸载时或使用按钮:
这可能不起作用/告诉您需要知道什么,因为当脚本断开连接时 IE 可能拒绝执行垃圾收集。这可能是因为 IE 在执行此操作时实际上不会卸载它们,或者只是因为 IE - 好吧,oddi 所说的:)
无论如何,这都不是解决方案;无论 JS 何时被卸载,垃圾收集仍然需要相同的时间。这只是第一次诊断的尝试,就像您所要求的那样。希望它有效/有帮助...
This is a long shot as there are about eleventy-hundred things wrong with it, but it might be somewhere to start. Add this script tag to your page as the very last one:
This code attempts to force the unload of each of the JavaScript files that were loaded on the page, reporting the amount of time it takes to drop them in milliseconds. Fire this as is convenient, i.e., on unload or with a button:
This might not work/tell you what you need to know because IE could refuse to do garbage collection when the script is disconnected. This could be because IE really doesn't unload them when you do this, or just because IE - well, what oddi said :)
In any event, this isn't a solution; it doesn't matter when the JS gets unloaded, garbage collection still takes the same amount of time. This is just an attempt at a first diagnosis, like you asked for. Hope it works/helps...
是的,IE 很糟糕。但是有几种工具可以分析您的页面。
Fiddler 或 HttpWatch 是一个很好的工具,用于分析您的请求时间线并查看下载所有繁重的 JavaScript 代码是否需要很长时间。这通常是减慢沉重的 js 页面速度的主要原因。由于IE不能很好地并行下载js< /a>,数百个小 javascript 文件会花费更多时间。
对于这种情况,请尝试缩小您的 JavaScript。这是增强页面加载性能的最直接方法。
如果没有太大帮助的话。您可能需要YSlow来分析详细的性能。虽然它不适合 IE,但修复 Chrome 或 FF 下的一些问题可能会影响 IE 下的性能。
在你的控制台添加一些日志,缩小范围也许你可以发现执行性能问题。
Yes IE sucks. But there are several tools to profile your page.
Fiddler or HttpWatch is a good tool for analysing your request timeline and see whether it takes long time to download all your heavy javascript code. It's often the main cause of slowing down a heavey js page. Since IE doesn't take parallel downloading js very well, it costs more time for hundreds of small javascript files.
For this case, try minifying your javascript. It is the most direct way to enhance your page load performance.
If it doesn't help much. You may need YSlow to analyse a detailed performance. Although it doesn't fits IE, fixing some issues under Chrome or FF can affect performance under IE.
Add some log in your console, narrow down the scope maybe you can find the execution performance problem.
也许您正在使用像 PrototypeJS 这样的 Javascript 库,它挂钩页面
unload
事件,当页面卸载时,它会循环遍历一个数组,删除页面上所有 DOM 元素的所有事件侦听器。如果我们知道您正在使用哪些库,我们可以模拟调用卸载页面以强制库执行其卸载函数。然后,启动计时器来查看加载另一个页面需要多长时间。Maybe you're using a Javascript library like PrototypeJS that hooks onto the page
unload
event and when the page unloads, it loops through an array removing all the event listeners for all the DOM elements on the page. If we know what libraries you are using, we could simulate a call to unload the page to force the library to execute it's unload function. Afterwards, start a timer to see how long it takes to load another page.