javascript 如何以编程方式更改 Firefox 中的 about:config dom.max_script_run_time 值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14703594/
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
How to programatically change the about:config dom.max_script_run_time value in Firefox?
提问by Lucky
I am just wondering if there is any way to programatically change the dom.max_script_run_timevalue in the Firefox about:configwindow.
我只是想知道是否有任何方法可以在 Firefox about:config窗口中以编程方式更改dom.max_script_run_time值。
When the default values in my Firefox is 10, I think its too less to run a script running for longer time in my website. On when the value is set to default(i.e.10) my firefox goes Not Respondingand I get warning alert message like Warning: Unresponsive ScriptI just need to set the value to 20 or 30 to avoid any such alerts popping often and let the script to run for longer time.
当我的 Firefox 中的默认值是 10 时,我认为在我的网站上运行长时间运行的脚本太少了。当该值设置为默认值(即 10)时,我的 Firefox 将没有响应,并且我收到警告警报消息,例如警告:无响应脚本我只需要将该值设置为 20 或 30 以避免任何此类警报经常弹出并让脚本运行更长的时间。
So I just need to change the dom.max_script_run_timeeach time the page gets loaded.
所以我只需要在每次加载页面时更改dom.max_script_run_time。
I have tested this in other browsers like Firefox, Chrome, Safari, Palemoon and Opera..
我已经在 Firefox、Chrome、Safari、Palemoon 和 Opera 等其他浏览器中对此进行了测试。
I have this problem only in Firefox
我只在 Firefox 中遇到这个问题
Or is there any other way rather than changing the settings and loading the page?
或者有没有其他方法而不是更改设置和加载页面?
Any solution will be appreciated.
任何解决方案将不胜感激。
采纳答案by Lucky
Anyway I found another solution to solve this problem. And thats Defered loading of JSconcept from page speed insights. Got the help from here..I have added the code below to load the javascript file asynchronously after the page is loaded. This stops displaying the non responsive script warning in Firefox.
无论如何,我找到了另一个解决方案来解决这个问题。这就是从页面速度洞察中延迟加载 JS概念。从这里得到帮助..我添加了下面的代码以在页面加载后异步加载 javascript 文件。这将停止在 Firefox 中显示非响应脚本警告。
Now all my javascript functions stored in the someScript.jsis called just after the page stops loading and with a small time elapsed in between. But thats not a problem as far as I don't get the unresponsive script error.
现在我存储在someScript.js中的所有 javascript 函数都在页面停止加载之后被调用,并且中间经过了一小段时间。但这不是问题,因为我没有收到无响应的脚本错误。
Deferred Loading of JS:
JS 的延迟加载:
<script type="text/javascript">
// Add a script element as a child of the body
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "/js/someScript.js";
document.body.appendChild(element);
}
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else
window.onload = downloadJSAtOnload;
</script>
回答by Lucky
definitely, you can't change that value via web. I'm 100% sure
当然,您不能通过网络更改该值。我 100% 确定
you should try to redesign your scripts and make your pages lighter
你应该尝试重新设计你的脚本并使你的页面更轻
for example you should avoid, sadly, on firefox, as best you can
例如,遗憾的是,您应该尽可能避免使用 Firefox
- border-radius
- box-shadow
- text-shadow
- dynamic gradients like -moz-linear-gradient -moz-radial-gradient etc
- transitions/animations and transforms
- frequent text rendering and re-rendering
- huge backgrounds especially with background-attachment:fixed
- flash objects, canvas, svg
- 边界半径
- 盒子阴影
- 文字阴影
- 动态渐变,如 -moz-linear-gradient -moz-radial-gradient 等
- 过渡/动画和变换
- 频繁的文本渲染和重新渲染
- 巨大的背景,尤其是背景附件:固定
- Flash 对象、画布、svg
回答by Allanah Anderson
Set integer to 1000 or 0 at about:config dom.max.script_run_time.
在 about:config dom.max.script_run_time将整数设置为 1000 或 0 。
I have found this to be a reliable fix and Firefox no longer has the
我发现这是一个可靠的修复程序,Firefox 不再具有
Warning: Unresponsive Scripterror message, runs alot faster and is an
警告:无响应的脚本错误消息,运行速度更快,是一个
immediate fix.
立即修复。