Explain the Critical Rendering Path
Interview Question: "Walk me through what happens from when the browser receives an HTML response to when the user sees pixels on screen."
The Senior Answer
Don't just list steps. Show you understand why each step exists and what blocks what.
"The Critical Rendering Path is a six-stage pipeline: HTML parsing builds the DOM tree, CSS parsing builds the CSSOM tree, these merge into the Render Tree (only visible elements), Layout computes geometry, Paint converts to pixels, and Compositing sends layers to the GPU. What makes this interesting architecturally isn't the steps â it's the blocking relationships between them."
The Pipeline in 30 Seconds
HTML â DOM
CSS â CSSOM â Render Tree â Layout â Paint â Composite
JS (can modify DOM & CSSOM)Key blocking points:
- CSS is render-blocking â Browser won't paint until all CSS is parsed (because later rules can override earlier ones)
- Synchronous JS is parser-blocking â The HTML parser stops completely until the script downloads and executes
- JS can be CSSOM-blocking â If CSS is still loading and a script might read styles, the script waits for CSS
"This means a single
<script>tag in<head>withoutdeferorasynccreates a triple dependency: HTML parsing waits for the script, the script might wait for CSS, and rendering waits for both. That's why we inline critical CSS and defer scripts."
The Follow-Up Questions
"How do async and defer affect this?"
"
deferdownloads the script in parallel but delays execution until after HTML parsing completes. Scripts execute in document order.asyncalso downloads in parallel but executes immediately when ready â pausing the parser briefly. Usedeferfor app scripts that depend on DOM or each other. Useasyncfor independent scripts like analytics."
"What's the difference between Layout, Paint, and Composite?"
"Layout computes where things go â positions, sizes, resolving percentages and flexbox. Paint determines what they look like â colors, text, shadows, borders. Compositing merges painted layers on the GPU.
The cost hierarchy matters: changing
widthtriggers all three. Changingcolorskips layout. Changingtransformoropacityonly triggers compositing â which is why CSS animations using transform are dramatically cheaper than those using top/left."
"How would you optimize the CRP for a slow-loading page?"
"I'd work through three strategies:
- Reduce critical resources â Inline critical CSS in
<head>, defer all JavaScript, eliminate render-blocking resources- Minimize critical bytes â Preload key resources like fonts and hero images, use compression (Brotli)
- Shorten the critical path â Reduce the chain of serial requests. If HTML loads CSS which loads a font, that's 3 round trips before first paint. Preload the font directly from HTML to flatten it to 1 round trip."
"What are reflows and repaints?"
"A reflow (layout recalculation) happens when geometry changes â width, height, margin, font-size. It's the most expensive because it can cascade through the tree. A repaint happens when visual properties change without affecting geometry â color, background, box-shadow. The worst case is forced synchronous layout â reading a layout property like
offsetHeightwhile layout is dirty forces the browser to recalculate immediately, and doing this in a loop is called layout thrashing."
"How does this relate to Core Web Vitals?"
"FCP (First Contentful Paint) measures when the first content appears â directly gated by CRP. LCP (Largest Contentful Paint) measures when the main content is visible â often delayed by slow images, fonts, or render-blocking resources. CLS (Cumulative Layout Shift) happens when layout changes after initial paint â caused by images without dimensions, injected content, or late-loading fonts. INP (Interaction to Next Paint) measures how fast the browser responds to input â blocked by long tasks on the main thread."
The Answer That Wins
Structure it as: Pipeline â Blocking relationships â Optimization strategy â Measurement.
Don't just describe what happens â explain the performance implications of each step and what you'd do about them.
Red Flags in Your Answer
- Skipping CSSOM (many candidates only mention DOM)
- Not knowing that CSS is render-blocking
- Saying "the page loads" without explaining the stages
- Not connecting CRP to Core Web Vitals
- Missing the Layout â Paint â Composite cost hierarchy
- Not mentioning
defer/asyncas optimization strategies