[whatwg] Reliably Minimize Reflows

Boris Zbarsky bzbarsky at MIT.EDU
Sat Sep 26 11:11:21 PDT 2009


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?

-Boris


More information about the whatwg mailing list