From URL to pixels
Between pressing Enter and seeing a page, the browser runs the same stages every time, in the same order. Here they are one message at a time, from the DNS lookup to the first pixel, with what each one costs.
01 What the browser reads in a URL
The browser first decides whether you typed a URL or a search. A URL is then split into parts, and each part feeds a different stage.
| Part | Value | Used by |
|---|---|---|
| Scheme | https | Connect and TLS: port 443, encrypted |
| Host | shop.example | DNS, then the TLS certificate check |
| Path | /cart | The HTTP request line |
| Query | ?item=7 | Sent with the path; the server reads it |
Before anything goes on the network, the browser also checks its HTTP cache. If it holds a fresh copy of the page, every network stage below is skipped. Assume here that it does not.
02 The whole trip, one message at a time
A first visit to https://shop.example/, whose page links one stylesheet. The top row is the stage in progress. The list below it is every message on the network, in order. A round trip is one message there and its reply back, the unit that network delay is paid in.
- stage running
- done, or sent earlier
- message just sent
- stage not reached
You press Enter on https://shop.example/. The browser splits it into scheme https, host shop.example and path /. Nothing has been sent yet.
203.0.113.10 is an address reserved for documentation. With HTTP/3 the connection runs over QUIC, which does the transport and TLS handshakes together in one round trip, so Connect and TLS merge.
03 Each stage in one line
| Stage | What happens | Slow when |
|---|---|---|
| DNS | Host name becomes an IP address | The name is not cached and the resolver is far away |
| Connect | TCP handshake with the server | The server is far away: one full round trip |
| TLS | Keys agreed, certificate checked | TLS 1.2 (two round trips) or a long certificate chain |
| Request | HTTP request out, response back | The server is slow to generate the page |
| Parse | HTML into the DOM, CSS into the CSSOM | Scripts in the head block the parser |
| Style | Computed style for every element | Very many elements or complex selectors |
| Layout | Size and position of every box | Large pages, or layout forced again and again |
| Paint | Pixels drawn, layers composited | Big areas, heavy shadows and filters |
The first four stages are mostly waiting on the network, so their cost is set by distance. The last four run on your machine, so their cost is set by the page.
04 See it yourself
curl can report when each network stage finished. The times are seconds since the start, so each one includes the stages before it.
One real run; yours will differ. Subtract neighbours to get each stage: here TCP took about 7 ms, TLS about 17 ms and the server about 18 ms. For the rendering stages, open the browser’s DevTools: the Network panel’s Timing tab splits each request the same way, and the Performance panel shows Parse, Style, Layout and Paint as separate blocks.
05 What the second visit skips
Cache-Control lifetime that has not run out, the browser uses its copy and goes straight to parsing.Even with a new connection, TLS session resumption can make the TLS stage cheaper. Rendering, though, is never skipped: every visit still parses, styles, lays out and paints.
06 When the order bites
http://shop.example → https://shop.example/Redirects repeat the tripEach redirect is a whole extra request and response, often on a new connection with its own handshakes. Link to the final URL; HSTS lets the browser go straight to https on later visits.<script src="app.js"></script> in <head>Scripts that stop the parserA plain script makes the parser stop, fetch it and run it before reading more HTML. Use defer (run after parsing) or async (run when loaded) unless the script must run first.<link rel="stylesheet" href="/app.css">CSS holds back the first paintThe browser will not paint until the stylesheets in the head have loaded, so a slow CSS file means a blank page. Keep critical CSS small and served from the same origin.fonts.example, cdn.example, api.exampleEvery new origin pays againEach other host needs its own DNS lookup, TCP and TLS. <link rel="preconnect" href="https://cdn.example"> starts that work early.