How to determine the best "framerate" (setInterval delay) to use in a JavaScript animation loop?
<p>When writing a JavaScript animation, you of course make a loop using setInterval (or repeated setTimeout). But what is the best delay to use in the setInterval/setTimeout call(s)?</p>

<p>In the <a href="http://api.jquery.com/animate/">jQuery API page for the .animate() function</a>, the user "fbogner" says:</p>

<blockquote>
  <p>Just if anyone is interested: Animations are "rendered" using a setInterval with a time out of 13ms. This is quite fast! Chrome's fastest possible interval is about 10ms. All other browsers "sample" at about 20-30ms.</p>
</blockquote>

<p>Any idea how jQuery determined to use this specific number?</p>

<hr>

<p>Started bounty. I'm hoping someone with knowledge of the source code behind Chromium or Firefox can provide some hard facts that might back up the decision of a specific framerate. Or perhaps a list of animations (or frameworks) and their delays. I believe this makes for an interesting opportunity to do a bit of research.</p>

<hr>

<p>Interesting - I just took the time to look at Google's <a href="http://www.google.com/pacman">Pac-Man</a> source to see what they did. They set up an array of possible FPSes (90, 45, 30), start at the first one, and then each frame they check the "slowness" of the frame (amount the frame exceeded its allotted time). If the slowness exceeds 50ms 20 times, the framerate is notched down to the next in the list (90 -> 45, 45 -> 30). It appears that the framerate is never raised back up, presumably because the game is so short-lived that it wouldn't be worth the trouble to code that.</p>

<p>Oh, and the setInterval delay is of course set to 1000 / framerate. They do, in fact, use setInterval and not repeated setTimeouts.</p>

<p>I think this dynamic framerate feature is pretty neat!</p>
