Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

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.

All Replies (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.

Modified by castrwilliam