Browser Rendering Pipeline
Understanding how a browser renders is critical for optimizing frontend performance:
- DOM/CSSOM Construction: Parsing HTML and CSS.
- Render Tree: Combining DOM and CSSOM.
- Layout (Reflow): Calculating the geometry (position/size) of each node.
- Paint: Filling in pixels.
- Compositing: Layering the painted parts.
Crucial Point: useLayoutEffect runs synchronously after Layout but before Paint, whereas useEffect runs after Paint.