layout
The rendering stage in which the browser calculates the exact position and size of every box on the page.
In more detail
Layout, also called reflow, runs after styles are known and before paint. Changing geometry such as width, height or top, or adding elements, makes the browser redo layout, often for large parts of the page, which is expensive.
Example
React keeps DOM changes to a minimum and applies them together in the commit phase.Related terms
- paint — The rendering stage that records how to fill in each box's pixels: text, colours, borders, shadows and images.
- compositing — The final rendering stage, in which separately painted layers are stacked and drawn together on screen, usually by the GPU.
- layout thrashing — Slowing a page by repeatedly changing styles and then reading sizes, forcing the browser to recalculate layout again and again.
- render tree — The tree of visible elements with their computed styles, built from the DOM and CSSOM, that the browser uses for layout and painting.
- DOM — The tree of objects a browser builds from a web page, which scripts read and change to update what is on screen.
- getBoundingClientRect — A browser method that returns an element size and its position relative to the visible part of the page.
Taught in
- CSS Parsing, The CSSOM And The Render Tree — Frontend Architecture & Web Platform
- Layout, Reflow, Paint And GPU Compositing Layers — Frontend Architecture & Web Platform
- DOM Manipulation: DocumentFragment And HTML Templates — Frontend Architecture & Web Platform
- Modern CSS Animations, Transitions And View Transitions API — Frontend Architecture & Web Platform
- Props Contract: Immutability, Children, And Polymorphic Tags — React 19 & Modern Component Architecture
- Virtual DOM vs Real DOM: The Reconciliation Cost Model — React 19 & Modern Component Architecture
- Diffing Algorithm: Element Type Shifts And Subtree Tear Down — React 19 & Modern Component Architecture
- useLayoutEffect vs useEffect: Painting And Synchronous Reads — React 19 & Modern Component Architecture
- Compound Components: Inversion of Control with Context — React 19 & Modern Component Architecture
- Higher-Order Components And Render Props: Tradeoff Analysis — React 19 & Modern Component Architecture
- Slot Patterns And Headless UI Architecture in React — React 19 & Modern Component Architecture
- React Portals: Escaping Stacking Contexts for Modals — React 19 & Modern Component Architecture
- Virtualization: Rendering Infinite Datasets Efficiently — React 19 & Modern Component Architecture