Skip to content Skip to sidebar Skip to footer

Do Reflows Occur Once For Each Applied Style?

When i do this in javascript: element.style.width='100px'; element.style.height='100px'; Am i right to say that there are 2 reflows in the document? And if i do this: element.setA

Solution 1:

Yes, there will be two reflows in the first example, and only one in the second. Check out When does reflow happen in a DOM environment?.

Solution 2:

When i do this in javascript:

element.style.width="100px"; element.style.height="100px";

Am i right to say that there are 2 reflows in the document?

Most unlikely. Reflows take (comparatively) a lot of time so they tend to only happen during JavaScript execution when they need to, for example when a piece of JavaScript reads back a property that depends on it's layout, e.g. offsetWidth.

But the details will be implementation dependent.

Post a Comment for "Do Reflows Occur Once For Each Applied Style?"