-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the problem
I was just recently made aware of the CSS contain property after it was added to the new Safari TP (136). It helps reduce layout rendering times when changing styles by containing the "layout" event to smaller portions of the page. the MDN docs explain it quite well:
The contain CSS property allows an author to indicate that an element and its contents are, as much as possible, independent of the rest of the document tree. This allows the browser to recalculate layout, style, paint, size, or any combination of them for a limited area of the DOM and not the entire page, leading to obvious performance benefits.
I've found an article showing some pretty significant performance improvements. From 28ms to 14ms going from none to strict.
Describe the proposed solution
It would be neat if Svelte could somehow do this automatically somehow. Maybe a compiler option that lets you turn on aggressively adding the property to elements inside of components or even wrapping them using the same solution we're using for custom CSS properties.
Alternatives considered
Doing it manually.
Importance
nice to have