How Browsers Render a Page: The Critical Rendering Path

Matt George

Fractional CTO · Founder of Injuria.ai

•6 min read•

Getting the HTML file to the browser is only half the work. The other half is turning that file, plus its stylesheets, scripts, and images, into something a person can see and use.[7][8] Browsers do this through a series of steps engineers call the critical rendering path.[1] Learning it changes how you think about performance, because it explains why a page can finish downloading and still sit blank, and why a single poorly placed script can freeze everything.

From HTML to the DOM

The browser reads the HTML as a stream of bytes and parses it into a tree of objects called the Document Object Model, or DOM. Each tag becomes a node, and nesting in the markup becomes parent and child relationships. Parsing is incremental: the browser does not wait for the entire file before it starts building the tree, which is why you sometimes see the top of a page appear before the rest has loaded. The DOM is also the thing your JavaScript talks to later when it reads or changes the page.[2]

From CSS to the CSSOM

Stylesheets go through a parallel process into the CSS Object Model, or CSSOM, which holds every rule and works out which styles apply to which elements, including inherited ones and the browser's defaults. CSS has an important property: it is render blocking by default. The browser will not paint until it has processed the CSS, because painting first and restyling after would flash unstyled content at the user. There is a useful lever hidden in that word "default," though. A stylesheet tagged with a media attribute that does not match the current situation, like media="print", is downloaded at low priority and does not block rendering, which is one of the cleaner ways to keep non-critical CSS out of the critical path.

Combining them into the render tree

With the DOM and CSSOM built, the browser combines them into the render tree, which contains only what will actually be shown. Elements set to display: none are left out entirely, because they take up no space, while something with visibility: hidden stays in, because it still occupies a box. The render tree is the set of visible things paired with the styles that apply to them, and it is the input to the two steps that produce pixels.

Layout: working out geometry

Layout, sometimes called reflow, is where the browser calculates the exact size and position of every box, starting from the viewport and working down the tree. Percentages, flexbox, grid, and text wrapping all resolve here into concrete coordinates. Layout is expensive, and it is easy to trigger by accident: when JavaScript changes something that affects geometry and then immediately reads a measurement back, it forces the browser to redo layout synchronously, over and over, in what is known as layout thrashing.[4] A smooth page avoids making the browser recompute geometry more than it has to.[9]

Paint, raster, and compositing

Once the browser knows where everything goes, it paints, and it is worth being precise about what that means in a modern engine, because it is not one step. First the main thread produces a display list, a set of drawing instructions. Then rasterization turns those instructions into actual bitmaps, work that is handed off to separate raster threads and the GPU. Finally compositing combines the resulting layers in the right order and draws them to the screen.[5]

This split is the key to smooth animation. Some changes, like moving an element with a transform or adjusting opacity, can be handled by the compositor alone, on its own thread, without redoing layout or paint, which is why those properties stay fluid even when the main thread is busy. Animating something like width or top forces layout and paint on every frame and is often janky as a result.

The main thread, and why scripts block

Here is the detail that ties the performance story together: DOM construction, CSSOM, layout, and paint-list generation all happen on a single main thread, the same thread that runs your JavaScript. Rasterization and compositing run elsewhere, which is exactly why compositor-only animations survive a busy main thread. But anything that needs the main thread competes with your scripts.

By default, when the HTML parser reaches a <script> tag, it stops and must download and run that script before continuing, because the script might change the document.[6] A large script high in the page blocks parsing, and everything after it. Browsers soften this with a preload scanner, a lightweight second parser that races ahead through the raw HTML while the main parser is blocked, discovering images and other resources and fetching them early.[3] You still want to help it: the defer attribute keeps parsing and runs the script after the document is ready, in order; async downloads in parallel but still pauses the parser when it executes, so it suits independent scripts like analytics rather than anything the page depends on.

<script src="/app.js" defer></script>

The milestones developers measure fall out of this: DOMContentLoaded fires when the DOM is built and deferred scripts have run, and load fires once images and the rest have finished.

Putting it together for speed

Lay the steps end to end and a strategy falls out. Get the HTML to the browser quickly so parsing can start. Keep render-blocking CSS small and deliver it fast, inlining the critical styles and offloading the rest with media. Keep scripts from blocking the parser with defer. Avoid forcing repeated layout from JavaScript. Animate only the properties the compositor can handle alone.

The reason some pages feel fast and others sluggish usually has little to do with how much was downloaded and everything to do with this path. My one-line version, after years of chasing these problems: performance is rarely about doing things faster, it is about not blocking the main thread and not making the browser redo work it already did. Almost every real fix is a variation on getting out of the browser's way.

Sources (9)
  1. MDN Web Docs: Critical rendering path
  2. MDN Web Docs: Populating the page, how browsers work
  3. web.dev: Don't fight the browser preload scanner
  4. web.dev: Avoid large, complex layouts and layout thrashing
  5. Chrome for Developers: RenderingNG architecture
  6. HTML Standard (WHATWG): the script element
  7. Jennifer Robbins, Learning Web Design ("O'Reilly Media, Inc.", 2025)
  8. Richard Penman, Python Web Scraping (Packt Publishing Ltd, 2015)
  9. Pavel Panchekha, Chris Harrelson, Web Browser Engineering (Oxford University Press, 2025)

Recommended reading

Core Web Vitals: What Google Measures and Why It Matters13 min readA comprehensive technical reference on Google's Core Web Vitals, explaining how the LCP, INP, and CLS metrics are measured, their impact on SEO, and the strategic tradeoffs for engineering leaders.How Web Caching and CDNs Work7 min readThe fastest request is the one you never have to make. Web caching is the layered system that avoids repeated work, and it hides one of the genuinely hard problems in computing. Here is how it holds together, and how it quietly leaks private data when it goes wrong.The Evolution of Web Rendering: From jQuery to SSR, SSG, and ISR7 min readWhere a web page gets built, on the server or in the browser, has swung back and forth for twenty years. Each swing solved the previous era's pain and created new pain of its own. Here is the full arc, and why it is not going in circles.Web Accessibility: The WCAG Basics Every Team Should Ship12 min readA technical guide for software engineers and leaders on implementing web accessibility using the Web Content Accessibility Guidelines (WCAG), covering its principles, technical mechanisms, and practical tradeoffs.WebSockets vs. Server-Sent Events vs. Polling: Real-Time Web Options14 min readA detailed comparison of polling, Server-Sent Events, and WebSockets, explaining their mechanisms, tradeoffs, and ideal use cases for building real-time web applications.What WebAssembly Is and Why It Matters7 min readFor most of the web's life, the browser had one native language. WebAssembly changed that by giving the browser a fast, portable compile target that any language can reach, and it is quietly becoming a runtime far beyond the browser.