Use the rendering path as a diagnostic model

Browsers interpret HTML and CSS to produce pixels, but they do not run every page through one complete, one-time sequence of DOM → CSSOM → render tree → layout → paint → compositing. Parsing and resource loading can overlap, and a script, style, image, or user interaction may trigger only the calculations needed for an update. The familiar stage names are most useful as a model for reading performance traces.

Broadly, the browser builds DOM nodes and computes styles; when needed, it calculates layout geometry, records paint work, and composites content. display: none does not produce a layout box, while visibility: hidden generally preserves its space. Stylesheet loading can affect the first render, but it does not mean every page always remains entirely blank until every stylesheet has downloaded. Document structure, script dependencies, and browser behavior matter.

What a CSS change may cost

Example changeWork the browser may need to revisitClue to inspect in a trace
Change width or font sizeLayout, followed by paint/compositing as neededLong Layout or Recalculate Style events and affected-node scope
Change a shadow or backgroundPaint and compositingLong Paint or raster work
Change transform or opacitySometimes only layer updates and compositingWhether paint is skipped, and whether extra layers or memory are used

The last row is not a guarantee. The property, effect, layer promotion, browser, and device can still require paint or raster work; GPU use is not fixed. Applying will-change everywhere or promoting every element can increase memory and compositing costs.

Narrow the cause in DevTools

  1. Record the interaction in Chrome DevTools Performance and select a long frame. The trace is an observation of that browser, device, and page run, not a guarantee about other environments.
  2. On the Main track, inspect time in Recalculate Style, Layout, and Paint. If code reads getBoundingClientRect() or offsetHeight immediately after changing styles, check whether that read forces synchronous layout.
  3. If layout repeats, avoid interleaving writes and geometry reads in one loop. Batch DOM updates, then read required geometry, and compare another trace under the same conditions.
  4. If paint dominates, inspect the affected area and CSS effects. An experiment with transform or opacity should compare frame time and layer memory; keep it only if the target devices benefit.

Hypothetical example: opening a card

If an animation changes a card’s height every frame, surrounding content may need repeated layout. Replacing it with a transform/opacity transition inside a fixed area may reduce reflow, but it is unsuitable if content becomes clipped or accessibility behavior changes. This is a hypothetical explanation of a possible cause and experiment, not a measurement. Decide by comparing actual traces using the steps above.

SSR and image dimensions are separate questions

Server-side rendering changes when initial HTML arrives and when client hydration runs; it does not automatically improve LCP or INP. Measure response time, blocking resources, client scripts, and content structure together. Providing intrinsic image dimensions or an aspect ratio can reserve space and help reduce layout shifts, but it does not remove shifts caused by image decoding, font swaps, or other sources.

Sources: MDN Critical rendering path, MDN How browsers work, Chrome DevTools Performance.