3 ms·
One other detail to keep in mind is that #3 can only happen once the browser has done DOM layout, and layout can be extremely expensive these days if you have m
by kevingadd 7y ago
One other detail to keep in mind is that #3 can only happen once the browser has done DOM layout, and layout can be extremely expensive these days if you have many elements and remotely complex CSS styles. The guarantees provided by contain also make layout faster.
One common source of performance issues is that certain JS DOM operations implicitly force the browser to do new layout, so you can end up having to wait for it.
- _bxg1 7y agoI wouldn't say "common". If you avoid "DOM thrashing" (where your code repeatedly mutates the DOM and then measures it and then mutates and then measures), the browser is pretty good at batching these computations and the vast majority of projects will never run into this as a problem. And thrashing is something you should solve by improving your JS, not mitigate with this API.