Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Is it possible to put a hard limit on how much CPU is used by JavaScript execution?

more options

Even today, there are tons of Web pages with JavaScripts on them that seem to peg the CPU usage. Usually, the browser will completely freeze for a while (15 seconds, and it won't respond to clicks whatsoever - the only thing possible during that time is to terminate or kill it). It will always recover from said hang. About 30-40% of the time, there will be a dialog that offers to stop execution of the script.

It has a checkbox that says "don't ask me again", which I checked... but it seems that Firefox takes that as "don't terminate scripts ever", not "whenever this dialog box is about to be displayed, take this marked check as my implicit approval to halt the script without asking."

I'm not completely sure if it's something to do with the engine itself, the pages, or something else, but I'm wondering if such an option exists.

Even today, there are tons of Web pages with JavaScripts on them that seem to peg the CPU usage. Usually, the browser will completely freeze for a while (15 seconds, and it won't respond to clicks whatsoever - the only thing possible during that time is to terminate or kill it). It will always recover from said hang. About 30-40% of the time, there will be a dialog that offers to stop execution of the script. It has a checkbox that says "don't ask me again", which I checked... but it seems that Firefox takes that as "don't terminate scripts ever", not "whenever this dialog box is about to be displayed, take this marked check as my implicit approval to halt the script without asking." I'm not completely sure if it's something to do with the engine itself, the pages, or something else, but I'm wondering if such an option exists.

所有回覆 (3)

more options

Hi castrwilliam, I do not know in the user interface, but all of the ways that these are controlled can be played with

  1. In the Location bar, type about:config and press Enter. The about:config "This might void your warranty!" warning page may appear.
  2. Click I'll be careful, I promise!, to continue to the about:config page.
  3. Search for javascript
more options

Start Firefox in Safe Mode to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).

  • Do NOT click the Reset button on the Safe Mode start window.
more options

I already looked in about:config. Nothing there seems to be of useful here. All that the options there mention is memory management. There's a "javascript.options.mem_notify", which sounded vague enough to maybe also control that, but apparently it's there to help developers optimize add-ons: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/GC/Statistics_API

I just relaunched in safe mode this morning and nothing seems to be acting up yet. The problem was intermittent so I'm not going to say that fixed it completely, but it's a definite improvement.

由 castrwilliam 於 修改