W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2009

[whatwg] Reliably Minimize Reflows

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sat, 26 Sep 2009 14:11:21 -0400
Message-ID: <4ABE5949.2050901@mit.edu>
On 9/26/09 12:04 PM, Joseph Pecoraro wrote:
> As I understand it, if there are 20 .foo elements then updating the
> style on each _could_ cause 20 individual reflows.

But generally won't.

> // Single reflow would be triggered at the end of batchUpdate
> document.batchUpdate(function() {
> ...
> });

As a UA developer, I'd not be all that happy implementing this, since 
you can stay inside the batchUpdate more or less forever (e.g. by 
putting up alerts or doing sync XHR).

In any case, it seems unnecessary.

> "Browsers may choose to wait until the end of a script thread before
> reflowing to show the changes. Opera will wait until enough changes have
> been made, enough time has elapsed, or the end of the thread is reached.
> This means that if the changes happen quickly enough in the same thread,
> they may only produce one reflow. However, this cannot be relied on,
> especially considering the various different speeds of devices that
> Opera runs on."

Note that Gecko will not perform layout while your script is running, 
unless you ask for layout information.  If Opera has a different 
behavior, I assume they have a good reason for it, right?  Why are you 
sure you want to override that reason?

Received on Saturday, 26 September 2009 11:11:21 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:52 UTC