[whatwg] A better animation API

Boris Zbarsky bzbarsky at MIT.EDU
Sat Dec 10 00:11:00 PST 2011


On 12/10/11 2:55 AM, Robert Eisele wrote:
> It's certainly also more difficult to implement but asking for every frame
> to continue has also the disadvantage of beeing as slow as setting up a new
> timeout for every frame. That's why setInterval surpass setTimeout's
> performance (okay, at least it should).

In theory, yes.

In practice, the actual cost of the requestAnimationFrame call is very 
very low.  And you have at most one of them per frame, right?

To quantify "very low", by the way, I just tried it in both Chrome and 
Firefox over here.  On my particular hardware (a laptop that's about 2 
years old), it's certainly under 3 microseconds per call.

So I really doubt there's a noticeable performance impact here.

> Maybe an API would also make sense, which runs for a given duration.

I could live with something like this, I think, if there are enough use 
cases.

-Boris



More information about the whatwg mailing list