What determines that a script is long-running?

本文探讨了不同浏览器如何判断脚本是否运行过长。Internet Explorer通过执行的语句数量来判断,默认为5百万条语句;Firefox通过脚本执行时间判断,默认为10秒;Safari默认超时时间为5秒;Chrome疑似采用时间限制,默认可能是10秒;而Opera似乎没有设置长时间运行脚本的限制。
  1. Internet Explorer determines that a script is long-running by the total amount of statements the JScript engine has executed . By default, the value is 5 million statements and can be altered via a registry setting .
  2. Firefox determines that a script is long-running by timing how long the script engine has been executing code continuously . The default time is set to 10 seconds and can be altered via about:config .
  3. Safari also uses script engine execution time to determine when a script has become long-running. After some digging around in the WebKit source code , it looks like the default timeout is 5 seconds.
  4. Chrome is a bit trickier to track down. The long-running script control seems tied to the crash control of any given tab. I’ve dug through the source code and haven’t been able to figure out the exact limit placed on scripts, but it does appear to be time-based and may be 10 seconds (it’s likely either 5 or 10, to match Safari or Firefox ).
  5. Opera is an interesting case: it doesn’t appear to have a long-running script limit . I ran several tests that completed even after minutes of code execution. During the time, the browser remain mostly responsive, which is impressive.

 原文出处:http://www.nczonline.net/blog/2009/01/05/what-determines-that-a-script-is-long-running/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值