W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2011

[whatwg] A better animation API

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sat, 10 Dec 2011 03:11:00 -0500
Message-ID: <4EE31414.8030006@mit.edu>
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
Received on Saturday, 10 December 2011 00:11:00 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:38 UTC