What happens when you load a URL?
The interview question, run as an actual experiment: every hop, with a stopwatch on it.
- Level
- ENGINEER
- Read time
- 14 min
- Experiment
- Available
- Type
- SIMULATION
The question
Between pressing Enter and seeing content, how much of the delay is network, how much is the server, and how much is your own JavaScript?
Hypothesis
On a typical connection the first paint is dominated by round trips, not by bandwidth, and the interactive delay is dominated by script execution, not by transfer.
Method
Laboratory available
The instrument for this investigation runs in the laboratory, where the controls, the live model and the observation log share one workstation.
Enter the laboratorySet the distance to the server, the protocol and the cache state. The bench animates each packet and reports the time budget of every phase.
Protocol
- 01Start on a cold cache, HTTP/1.1, server on another continent. Note the total.
- 02Switch to HTTP/2 and watch what changes, and what does not.
- 03Move the server to an edge location 20ms away. Compare the handshake cost.
- 04Enable a warm connection and observe how many round trips disappear.
What we observed
| Phase | Round trips | Notes |
|---|---|---|
| DNS | 0 to 2 | Often cached at the OS or resolver |
| TCP handshake | 1 | SYN → SYN-ACK → ACK |
| TLS 1.3 handshake | 1 | TLS 1.2 needed 2; 0-RTT resumption can reach 0 |
| QUIC (HTTP/3) first connection | 1 | Transport and crypto handshake are combined |
| HTTP request → first byte | 1 | Plus server think time |
At 150ms of latency, three round trips are 450ms spent before the server has even read your request line. This is why the single most effective 'performance optimisation' is often moving the origin closer, not shrinking the payload.
Why it happens
The journey
- 01URL parsing and scheme handling; HSTS may upgrade http:// to https:// with no network at all.
- 02DNS resolution: OS cache → resolver → recursive lookup.
- 03TCP (or QUIC) connection established to the resolved address.
- 04TLS handshake: certificate verification, key agreement, ALPN negotiates the HTTP version.
- 05The request is sent; the server responds with headers, then the HTML body.
- 06The HTML parser starts building the DOM incrementally as bytes arrive.
- 07Subresources are discovered, the preload scanner fetches them ahead of the parser.
- 08Render-blocking CSS must arrive and be parsed before the first paint.
- 09Scripts execute, hydration runs, and the page becomes interactive.
<script src="a.js"></script> <!-- blocks the parser --><script src="b.js" defer></script> <!-- parse continues, runs in order --><script src="c.js" async></script> <!-- parse continues, runs ASAP --><script src="d.js" type="module"></script><!-- deferred by default -->CSS is render-blocking but not parser-blocking, except that a script cannot run until pending stylesheets have loaded, because a script may read computed styles. That coupling is why a slow stylesheet can delay a script that has nothing to do with it.
Further research
TCP slow start means bandwidth is not available immediately. A new connection begins with a congestion window of roughly 10 segments (~14KB) and doubles each round trip. That is the real reason for the 'first 14KB' rule of thumb: whatever fits in the first flight arrives one round trip sooner than everything else.
References
- 01MDNPopulating the page: how browsers work
- 02web.devCritical rendering path
- 03IETF / QUIC WGHTTP/3 explained