Browser Rendering Pipeline (Critical Rendering Path)
The rendering engine executes five sequential phases: Style, Layout, Paint, Layerize, and Composite. Mutating geometric properties invalidates every downstream phase; mutating transform or opacity bypasses Style, Layout, and Paint directly to the Compositor Thread.
Frame Execution in Blink (16.6 ms at 60 Hz)
Observe which pipeline phases activate depending on the mutation type.
Script sets el.style.width = '320px'. The node is marked dirty for Style and Layout.
card.style.width = '320px';- dirtyFlags
- STYLE | LAYOUT | PAINT
- mainThread
- Blocked
- compositorThread
- Waiting
Under the Hood
Blink executes frame rendering as a strict unidirectional pipeline from Style through Layout, Paint, Layerize, and Composite. Modifying geometry at Layout invalidates every downstream stage, whereas mutating transform or opacity updates a GPU compositor matrix directly without re-running Style, Layout, or Paint.
- Style (Recalc Style): Blink matches every node from DOM & CSSOM Construction against CSSOM rules (governed by CSS Cascade Layers) and computes resolved
ComputedStylevalues (unless skipped offscreen via content-visibility). - Layout (Reflow): The engine computes exact geometry (boxes,
x/ycoordinates, widths, heights) in theLayoutTree. - Paint: Emits a list of draw instructions (
DisplayItems: backgrounds, borders, glyphs) sorted by CSS Stacking Context, without rasterizing yet. - Composite: The
Compositor Threadsplits GPU Compositor Layers into tiles, rasterizes them on GPU, and appliestransform/opacitywithout blocking the main thread.
/* Triggers Layout -> Paint -> Composite (expensive on main thread) */
.drawer.open {
left: 0;
width: 320px;
}
/* Skips Layout and Paint; runs on Compositor Thread */
.drawer-fast.open {
transform: translate3d(0, 0, 0);
}| Mutated Property | Triggered Phases | Main Thread Cost |
|---|---|---|
width / top / margin | Style -> Layout -> Paint -> Composite | High |
background-color / box-shadow | Style -> Paint -> Composite | Medium |
transform / opacity | Composite only (if promoted layer) | Near zero |
Problem Genealogy
- 1999 (DOM Level 1): Every DOM read/write triggers synchronous recalculations on a single thread, an architecture designed for static hypertext, later abused for interactive apps.
- 2008 (Hardware Acceleration): Separation of the
Compositor Threadto animate scrolling and transforms off the main thread. - 2021+ (RenderingNG): Modular pipeline architecture isolating each phase for parallel GPU rasterization.
Production Pitfalls
- Layout Thrashing: Reading
element.offsetHeightimmediately after writingelement.style.widthinside aforloop forces a synchronous Layout on every iteration, turning a 16 ms frame budget into a 200 ms stall. - Layer Explosion: Applying
will-change: transformto hundreds of nodes exhausts mobile GPU VRAM and crashes tabs.
- When not to use manual promotion: Do not force
translateZ(0)on static elements; let the engine promote layers only during active animations.
Connections & Logical Next Steps
- What This UnlocksThe Accessibility Tree and WAI-ARIA Semantics
- What This UnlocksCore Web Vitals Mechanics (LCP, INP, CLS)
- What This UnlocksCSS Houdini @property
- What This UnlocksDOM XSS Prevention with Trusted Types
- What This UnlocksGPU Compositor Layers and will-change
- What This UnlocksIntersectionObserver and Asynchronous Visibility
- What This UnlocksLayout Thrashing (Forced Synchronous Layout)
- What This UnlocksRender Tree & Layout
- What This UnlocksrequestAnimationFrame & VSync
- What This UnlocksVirtualized Lists & Windowing
CSS visibility (display: none, visibility: hidden) prunes nodes from the Accessibility Tree.
LCP, INP, and CLS directly measure paint timestamps, layout shifts, and next-frame presentation.
Type registration changes how the Style phase parses and interpolates custom properties.
DOM sinks invoke the HTML parser and script execution pipeline directly from JavaScript.
Promotion happens after Paint during the Layerize phase prior to GPU upload.
IntersectionObserver computes intersections once per frame immediately after the Layout phase.
Thrashing stems from repeated invalidation of the Layout phase.
Layout is the geometry-solving stage inside the main-thread frame pipeline.
Mutations inside rAF are batched directly into the upcoming Style/Layout/Paint cycle.
Rendering 10,000+ DOM nodes chokes style recalculation and layout passes; windowing caps active nodes.
Style calculation requires parsed DOM and CSSOM trees before constructing the render tree.
Delegates promoted element layers to the GPU compositor thread after paint and layerization.
Freezes the full DOM, layout tree, and compositor state in RAM to restore frames without re-parsing.
Evaluated during the Recalc Style phase when sorting CSSOM declarations.
Requires contain: inline-size (layout containment) to break parent-child circular dependencies.
Uses ancestor invalidation bitmasks and bloom filters during Recalc Style to avoid O(n^2) matching.
Stacking context order determines DisplayItem emission order during the Paint phase.
Coalescing pointermove writes into one rAF per frame prevents redundant style/layout work between VSyncs.
Offloading CPU work keeps the main thread free for style, layout, and paint deadlines.
DOM and CSSOM trees are the two mandatory inputs to Render Tree construction.
Update the Rendering runs only after the Microtask Queue is completely drained.
Stream prioritization determines whether CSS and fonts arrive before render-blocking frames.
ResizeObserver callbacks execute between Layout and Paint, triggering a second style recalculation cycle.
Presentation Delay reflects the Style, Layout, Paint, and Composite cost after the handler returns.
Governs availability of critical resources (CSS, fonts, LCP hero image) prior to first Paint.
content-visibility: auto skips Layout and Paint for offscreen subtrees instead of running the full pipeline.