javascript 在 IE 中很慢,但在 Firefox 中很快

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4398771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 12:15:41  来源:igfitidea点击:

javascript slow in IE but fast in Firefox

javascriptperformanceinternet-explorerfirefox

提问by George2

It is very slow to access this page using IE, but much faster using Firefox. Especially when I increase the number of nodes of people. Any ideas what is wrong?

使用 IE 访问此页面非常慢,但使用 Firefox 访问要快得多。特别是当我增加人的节点数时。任何想法有什么问题?

http://thejit.org/static/v20/Jit/Examples/RGraph/example1.html

http://thejit.org/static/v20/Jit/Examples/RGraph/example1.html

BTW: IE is even slow when accessing from local file system.

顺便说一句:从本地文件系统访问时,IE 甚至很慢。

thanks in advance, George

提前致谢,乔治

回答by darioo

Internet Explorer's Javascript engine is slower than that from other web browsers, at least when using IE with versions lower than 9. So, if you're using IE 6, 7 or 8, now you know why.

Internet Explorer 的 Javascript 引擎比其他网络浏览器慢,至少在使用版本低于 9 的 IE 时是这样。所以,如果您使用的是 IE 6、7 或 8,现在您知道原因了。

Like raynjamin said, try testing IE using Sunspider.

就像 raynjamin 所说的,尝试使用Sunspider测试 IE 。

The latest stable Firefox (3.6) is fast, but for example, Google Chrome is even faster. A browser's Javascript speed depends on its underlying implementation.

最新的稳定版 Firefox (3.6) 速度很快,但例如 Google Chrome 甚至更快。浏览器的 Javascript 速度取决于其底层实现。

Update: to give you an idea of how "fast" IE is compared to other browsers, I've done a benchmark on my own computer using Sunspider 0.9.1. Here are the results:

更新:为了让您了解 IE 与其他浏览器相比有多“快”,我在自己的计算机上使用 Sunspider 0.9.1 进行了基准测试。结果如下:

- Internet Explorer 8: 5039.8ms
- Firefox 3.6:          967.9ms (loaded with extensions)
- Chrome 9:             276.3ms
- Opera 10.6:           293.2ms
- Safari 5:             397.0ms

As you can see, IE 8 is about 5 times slower than Firefox 3.6 and almost 20 times slower than Chrome 9, at least when using Sunspider tests. That is a drastic difference and you can see that IE 8 isn't all that fast.

如您所见,至少在使用 Sunspider 测试时,IE 8 比 Firefox 3.6 慢约 5 倍,比 Chrome 9 慢近 20 倍。这是一个巨大的差异,您可以看到 IE 8 并不是那么快。

Update 2: There is one way to make IE faster. A plugin called Chrome frameexists. Using this plugin will make IE faster since it will use Chrome's engine. I haven't tried it personally, but I've heard good things about it.

更新 2:有一种方法可以使 IE 更快。存在一个名为Chrome 框架的插件。使用此插件将使 IE 更快,因为它将使用 Chrome 的引擎。我没有亲自尝试过,但我听说过关于它的好消息。

回答by Raynos

IE is slow. Fact.

IE 很慢。事实。

回答by raynjamin

Javascript runs much slower in IE than in other modern browsers. You can test it for yourself using a javascript benchmark like sunspider.

Javascript 在 IE 中的运行速度比在其他现代浏览器中慢得多。您可以使用像sunspider这样的 javascript 基准测试自己测试它。

回答by Shivam Tyagi

Guys Got the Culprit here... :) :)

伙计们在这里找到罪魁祸首... :) :)

After doing lot of RnD on Server side and Client side, I took a look at "Developer Tool" in IE. You can find something like "Document Mode: Quirks". If you check the Wiki page for this Quirks mode, You can find a definition as "In computing, quirks mode refers to a technique used by some web browsers for the sake of maintaining backward compatibility with web pages designed for older browsers, instead of strictly complying with W3C and IETF standards in standards mode."

在服务器端和客户端做了很多 RnD 之后,我看了一下 IE 中的“开发工具”。您可以找到类似“文档模式:怪癖”的内容。如果您查看此 Quirks 模式的 Wiki 页面,您可以找到定义为“在计算中,quirks 模式是指某些 Web 浏览器为了保持与为旧浏览器设计的网页的向后兼容性而使用的技术,而不是严格的在标准模式下符合 W3C 和 IETF 标准。”

So this all becuase of checking for compatibility for all components on page. And hence the performance issue. :)

所以这都是因为检查页面上所有组件的兼容性。因此,性能问题。:)

And When I changed this mode to IE 8 Standard. Things started working really well.

当我将此模式更改为 IE 8 标准时。事情开始运作得非常好。

IE and its issues ...!!!! :D

IE 及其问题...!!!! :D