|
|
|
|
|
by randallu
4524 days ago
|
|
The "translateZ: 0" description is a bit misleading -- I wish he'd provided numbers for the improvement. In general using composited layers is more expensive (since the CPU still does rendering of the image, must upload it to texture, etc). It might be a win if the thing you apply it to: 1. Never changes, but the content around it changes often. 2. Is hard to render (lots of shadows, etc). The layout and paint thrashing is a really good optimization though. You should be able to insert as many things into the DOM as you like without triggering a layout SO long as you don't read back (like consulting offsetLeft). I think the Chrome inspector will mark read backs with a little exclamation point in the timeline with a tooltip "synchronous layout forced" and a backtrace to your JS... |
|
The same thing works with all of the other 3d transforms: Putting in a BS value for Z will cause the element to use hardware acceleration.