Browser rendering pipeline
Critical rendering path, style/layout/paint/composite, what forces reflow, why transform and opacity animate cheaply. The foundation of every perf answer.
The mental model
The browser turns your HTML, CSS, and JavaScript into pixels through a fixed assembly line, and every performance answer you will ever give is really a statement about *which station on that line a given change forces to run again*. The stations, in order: parse HTML into the DOM, parse CSS into the CSSOM, combine them into the render tree, compute layout (geometry — where and how big), paint (fill in pixels into layers), and composite (assemble the layers on the GPU into the final frame). The line runs, in the ideal case, once per display refresh — roughly every 16.7ms on a 60Hz screen.
The analogy that sticks: a print shop. The DOM and CSSOM are the manuscript and the style guide. Layout is *typesetting* — deciding where every word sits on every page; change the page size and the whole book must be re-typeset. Paint is *inking* — filling in the already-positioned letters; you can re-ink a page in a new colour without re-typesetting it. Composite is *collating* — stacking the finished sheets in order; you can slide one transparent overlay sheet around over the others without touching the ink underneath. The reason transform and opacity animate at 60fps and top/width do not is exactly this: moving the overlay sheet (composite) is cheap; re-typesetting the book on every frame (layout) is not.
What breaks without this model is every "why is it slow" investigation. An animation that stutters is almost always animating a layout property, forcing typesetting 60 times a second. A page that freezes for a beat is running JavaScript that reads a geometry value mid-mutation, forcing the browser to typeset right now instead of batching. A late-appearing hero image tanks a metric because a render-blocking stylesheet held the whole line at the CSSOM station. Each is the assembly line behaving exactly as specified while you pictured pixels appearing by magic. Once you can name the station, the fix names itself.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision