title: How can I make setInterval also work when a tab is inactive in Chrome?
body: <p>I have a <code>setInterval</code> running a piece of code 30 times a second. This works great, however when I select another tab (so that the tab with my code becomes inactive), the <code>setInterval</code> is set to an idle state for some reason.</p>
  <p>I made this simplified test case (<a href="http://jsfiddle.net/7f6DX/3/" rel="noreferrer">http://jsfiddle.net/7f6DX/3/</a>):</p>
  <pre><code>var $div = $('div');
  var a = 0;
  
  setInterval(function() {
      a++;
      $div.css(&quot;left&quot;, a)
  }, 1000 / 30);
  </code></pre>
  <p>If you run this code and then switch to another tab, wait a few seconds and go back, the animation continues at the point it was when you switched to the other tab.</p>
  <p>So the animation isn't running 30 times a second in case the tab is inactive. This can be confirmed by counting the amount of times the <code>setInterval</code> function is called each second - this will not be 30 but just 1 or 2 if the tab is inactive.</p>
  <p>I guess that this is done by design so as to improve system performance, but is there any way to disable this behavior?</p>
  <p>It’s actually a disadvantage in my scenario.</p>