Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do browsers pause/change Javascript when tab or window is not active?
    text
    copied!<p>Background: I'm doing some user interface tests that need to detect if people are paying attention or not. But, this question is <strong>not</strong> about <a href="https://stackoverflow.com/a/1060034/586086">the page visibility API</a>.</p> <p>Specifically, I would like to know how my Javascript code will be affected if the current tab is not active, or the browser window is not active, in different browsers. I've dug up the following so far:</p> <ul> <li><a href="https://stackoverflow.com/q/7977170/586086">ios 5 pauses javascript when tab is not active</a></li> <li><a href="http://pivotallabs.com/chrome-and-firefox-throttle-settimeout-setinterval-in-inactive-tabs/" rel="noreferrer"><code>setInterval</code> and <code>setTimeout</code> delay is reduced when tabs are not active</a> - seems like this just started appearing recently and can mess up Jasmine unit tests, around other things.</li> <li><code>requestAnimationFrame</code> is slowed when tab is not active (reasonable, can't think of why this would affect anyone too much)</li> </ul> <p>I have the following questions:</p> <ul> <li>Other than mobile browsers, do desktop browsers ever pause JS execution when a tab is not active? When and which browsers?</li> <li>Which browsers reduce the <code>setInterval</code> repeat? Is it just reduced to a limit or by a percentage? For example, if I have a 10ms repeat versus a 5000ms repeat, how will each be affected?</li> <li>Do these changes happen if the <em>window</em> is out of focus, as opposed to just the tab? (I imagine it would be harder to detect, as it requires the OS API.) </li> <li>Are there any other effects that would not be observed in an active tab? Could they mess things up that would otherwise execute correctly (i.e. the aforementioned Jasmine tests)?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload