Javascript performance when running in an unfocused tab Javascript performance when running in an unfocused tab google-chrome google-chrome

Javascript performance when running in an unfocused tab


setTimeout and setInterval have been throttled to a minimum of 1000ms in unfocused tabs. Here is the Bugzilla report that mentions it. And here is the similar Chromium bug report. I believe this is the case in Firefox 5 and in Chrome since version 11.

According to MDN:

In (Firefox 5.0 / Thunderbird 5.0) and Chrome 11, timeouts are clamped to firing no more often than once per second (1000ms) in inactive tabs; see bug 633421 for more information about this in Mozilla or crbug.com/66078 for details about this in Chrome.

As for getting around this restriction, you could try the technique discussed in this article, but I haven't had a change to try it myself yet.


For Firefox in particular, you can change the dom.min_background_timeout_value preference in about:config to a number of your liking in the profile that you use to run the tests. I wouldn't suggest doing that in your default browsing profile, though: the reason for the high clamp is that it cuts down on web sites in background tabs chewing up CPU updating silly tickers and the like.


The change made was to increase (by a lot) the minimum timeout value. To my knowledge there's no way to control that; it's in the innards of the timer implementation. Both Chrome and Firefox do this now, maybe Safari too.

It gets pretty weird if you use "setInterval()", because it seems that the browser wants to make sure that the interval callback gets called the proper number of times. When you return to the page, you get a burst of activity from the interval timers as they catch up.