The fastest animation is the one that never touches layout

There is a version of this advice everyone has heard: animate transform and opacity, not width and height. It gets repeated often enough that it starts to sound like superstition. It is not. It is a plain description of how much work you are asking for on every single frame.

When you animate height, the browser cannot know what else moved until it measures. Every frame means layout, then paint, then composite, for the element you touched and for everything your change pushed around it. At sixty frames a second you have about sixteen milliseconds for all of that, and layout on a deep tree will spend it by itself. Transform and opacity skip the first two steps. The compositor already has the layer, and moving or fading it is work the GPU does without stopping to ask the main thread for permission.

The honest catch is that transform cannot do everything height does. Collapsing a disclosure panel to nothing is a layout change by definition, and scaling it instead looks wrong, because the text squashes along with the box. That is the gap interpolate-size and calc-size were added to close, and it is where a real height animation earns its cost. The rule was never that layout animation is forbidden. It is that you should know when you are paying for one.

The test takes a minute. Open the performance panel, record the interaction, and look for purple. If there is a layout block in every frame, you are animating the wrong property, and the machine you are testing on is almost certainly faster than the one your reader is holding.