3 ms·
Does anyone know if `contain` can increase paint performance of a webpage meaningfully? It seems like it can prevent unnecessary calls, but I'm wondering if the
by jjcm 2y ago
Does anyone know if `contain` can increase paint performance of a webpage meaningfully? It seems like it can prevent unnecessary calls, but I'm wondering if there's any reasonable impact it gives.
- netghost 2y agoYou'd want to benchmark this yourself, and assume that the impact will probably decrease as browsers progress, but I believe that for very large trees (tables, etc) it can have a fair impact. That said, I'm guessing paints aren't what are usually slowing your page down. A quick way to validate that is to open up the devtools and run a performance trace. Watch for paint events vs JS code execution and such.
- MatmaRex 2y agoProbably. I've encountered a case where setting `contain` for unrelated reasons noticeably decreased the GPU memory use as reported by the browser: https://phabricator.wikimedia.org/T373066#10096943 https://phabricator.wikimedia.org/T373066#10096943 (search for "As a bonus"). Wikipedia is pretty light, so in absolute terms it wasn't really meaningful, but I could see that on a more complex site.