<story><title>CSS Containment Specification</title><url>https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Containment</url></story><parent_chain></parent_chain><comment><author>_bxg1</author><text>For those who are a little unclear on what this is for, there are typically several layers of rendering at play in a modern web app:&lt;p&gt;1) Re-rendering of virtual DOM content&lt;p&gt;2) Mutating the real DOM to match that new virtual DOM&lt;p&gt;3) The browser actually drawing the new state of the DOM&amp;#x2F;styles&lt;p&gt;#1 is your JS code. #2 is covered opaquely by React and peers. #3 is traditionally covered opaquely by the web browser.&lt;p&gt;This API is a way of giving hints to #3 when that becomes your bottleneck (which is really quite rare, but when it happens, it&amp;#x27;s extremely nice to have a recourse). If you&amp;#x27;re experiencing &amp;quot;jank&amp;quot; and are unsure whether this will help, profile your app in Chrome and look for the purple &amp;quot;Reflow&amp;quot; bars in the flame chart. If your chart is mostly orange, your JavaScript is still your bottleneck.&lt;p&gt;This API is analogous to the compiler hints (assertions, etc.) you can add in certain native languages which allow the compiler to make certain assumptions and therefore optimize more aggressively, where it otherwise might have had to play it safe to ensure correctness.</text></comment>
<story><title>CSS Containment Specification</title><url>https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Containment</url></story><parent_chain></parent_chain><comment><author>destructionator</author><text>I don&amp;#x27;t understand why the browser can&amp;#x27;t infer this from existing knowledge. If it doesn&amp;#x27;t have any absolutely positioned or floating child elements, wouldn&amp;#x27;t that imply contain: content? And if you add overflow: auto or hidden, wouldn&amp;#x27;t that infer to contain: strict?&lt;p&gt;I like the idea of containing floats in a div easily, no more clear hacks lol. But... I must be missing something since it really seems to be these optimizations ought to already be possible.</text></comment>