The critical rendering path is the series of steps the browser must complete to render the initial view of a web page. Understanding this path is key to optimizing performance.
Steps in the critical rendering path
- Construct DOM: Parse HTML into Document Object Model
- Construct CSSOM: Parse CSS into CSS Object Model
- Execute JavaScript: Run scripts that may modify DOM/CSSOM
- Render Tree: Combine DOM and CSSOM
- Layout: Calculate element positions and sizes
- Paint: Draw pixels to screen
What blocks rendering
- Synchronous JavaScript in
<head> - CSS stylesheets
- Web fonts (can cause FOIT/FOUT)
Optimizing the critical rendering path
Minimize critical resources
- Inline critical CSS
- Defer non-critical JavaScript
- Minimize third-party scripts
Reduce critical bytes
- Minify CSS and JavaScript
- Compress resources (gzip/brotli)
- Eliminate unused code
Shorten critical path length
- Reduce number of round trips
- Preload critical resources
- Use HTTP/2 for multiplexing
Related Terms
First Contentful Paint (FCP)
A performance metric that measures the time from when the page starts loading to when any part of the page's content is rendered on screen.
JavaScript Execution Time
The time the browser spends parsing, compiling, and executing JavaScript code, which can block the main thread and delay interactivity.
Main Thread
The primary thread in a browser where JavaScript execution, DOM manipulation, and rendering operations occur.
Render Blocking
Resources that prevent the browser from rendering page content until they are fully downloaded and processed.