What you'll learn: By the end of this lesson you will be able to read each phase of a request in a waterfall (queueing, DNS, connection, waiting, download), explain why a request starts late (who revealed it), find the chain of requests that decides the first paint, and predict what
preload,preconnect, HTTP/2 and a warm cache change.
Think of a relay race. Each runner can start only when the previous one hands over the baton, and each handover needs a short walk. The race is not as slow as the sum of the runners' speeds: it is as slow as the longest chain of handovers. A waterfall is the race seen from above, and reading it means finding that chain.
The core idea
- A row is a request, and a row's start is a decision. A request starts when something names the resource: the HTML, a style sheet, a script. Before that it does not exist, however fast the network is.
- Each request pays for connection, waiting and download separately. Different slowness needs different fixes.
- The first paint depends on a chain, not a total. Shorten the chain (reveal things earlier, remove a hop) before you shave bytes off a file that is not on it.
What a row says
Chrome DevTools splits a request into phases. Queueing is time before the connection starts, and stalled is waiting after it, for the same reasons, including (for HTTP/1.0 and 1.1 only) that six TCP connections to the origin are already open. DNS lookup resolves the address. Initial connection covers the TCP handshake and TLS negotiation. Waiting (TTFB) is the wait for the first byte, which, per DevTools, "includes 1 round trip of latency and the time the server took to prepare the response". Content download reads the body. The browser's Resource Timing entries expose the same moments, from domainLookupStart to responseEnd.
The Initiator column tells you who revealed a request: the parser, a script, or another source. Following initiators upward is how you find the chain.
Figure 1. One request, phase by phase
How to read this: the setup steps happen once per connection. A new origin pays them in full, which is why a late request to a new origin is slow even when its file is small.
Why a request starts late
A resource named in the HTML can start as soon as the HTML is read. A resource named inside a style sheet (a font, an image) or requested by a script cannot start until that file has arrived and been processed. MDN's page on preload names exactly these: resources pointed to from inside CSS, like fonts or images, and resources that JavaScript can request. Chain those and each hop adds a connection, a round trip and a download before the next can begin.
Figure 2. A chain of reveals across origins
How to read this: the hero image cannot start before the script has been fetched and run, whatever the link speed. The chain, not the image's size, is what a preload hint attacks.
Where is the time going?
Figure 3. Choosing a fix from what the row shows
on this row?"} -->|"it starts late"| A["Find who revealed it:
preload, or remove a hop"] Q -->|"dots before the request"| B["Connection or queue:
preconnect, fewer origins, HTTP/2"] Q -->|"long wait for first byte"| C["Server time or round trip:
cache, closer server"] Q -->|"long download"| D["Size or shared link:
smaller file, priority"]
How to read this: the same slow total can come from four different causes, and each has its own remedy. Name the cause before choosing the fix.
Build it: a waterfall you can change
Goal. Run a pure model of one invented product page and read its waterfall, the chain that decides the paint, and six variants of the same page.
Setup. The lab is in the course's example workspace (Node 26.13.1, pnpm). It is a plain model: no browser, no real network.
cd examples/frontend
pnpm install
cd labs/waterfall-model
pnpm test # 22 tests
node src/demo.ts
Steps.
- Run the tests and the demo. In section 1, find the dotted stretch before
heroand beforethumb1: they wait on a connection. - In section 2, follow
heroup toapp.jsand thendoc. That is the critical path. - In section 3, compare "preload hero, font" with the baseline, then with "repeat visit".
- In section 4, see the same page with three round-trip times.
Expected output, captured from a real run (Node 26.13.1, 2026-12-01):
Reading a waterfall: one invented product page, run through a model of the network
=== 1. The baseline waterfall (HTTP/2, 80 ms round trip, 8000 kbps), 25 ms per column
legend: . waiting for a connection or a slot, w waiting for the first byte, # downloading
doc app.example |........wwwwwwwww# | 0 to 450 ms
app.css app.example | wwww## | 450 to 590 ms
app.js app.example | wwww###### | 450 to 700 ms
stats.js stats.example | ........wwww# | 450 to 770 ms
font static.example | .........www# | 595 to 900 ms
hero img.example | ........wwww########### | 760 to 1301 ms
api app.example | .wwwwwwww | 760 to 964 ms
thumb1 img.example | .wwww####### | 969 to 1245 ms
thumb2 img.example | .wwww####### | 969 to 1245 ms
thumb3 img.example | .wwww####### | 969 to 1245 ms
thumb4 img.example | .wwww####### | 969 to 1245 ms
thumb5 img.example | .wwww####### | 969 to 1245 ms
thumb6 img.example | .wwww####### | 969 to 1245 ms
thumb7 img.example | .wwww####### | 969 to 1245 ms
thumb8 img.example | .wwww####### | 969 to 1245 ms
=== 2. Reading it: who revealed what, and which request ended last
app.css revealed by doc at 450 ms (when the HTML finished)
app.js revealed by doc at 450 ms (when the HTML finished)
stats.js revealed by doc at 450 ms (when the HTML finished)
font revealed by app.css at 595 ms (145 ms after the HTML)
hero revealed by app.js at 760 ms (310 ms after the HTML)
api revealed by app.js at 760 ms (310 ms after the HTML)
thumb1 revealed by api at 969 ms (519 ms after the HTML)
thumb2 revealed by api at 969 ms (519 ms after the HTML)
thumb3 revealed by api at 969 ms (519 ms after the HTML)
thumb4 revealed by api at 969 ms (519 ms after the HTML)
thumb5 revealed by api at 969 ms (519 ms after the HTML)
thumb6 revealed by api at 969 ms (519 ms after the HTML)
thumb7 revealed by api at 969 ms (519 ms after the HTML)
thumb8 revealed by api at 969 ms (519 ms after the HTML)
critical path: doc -> app.js -> hero
first paint possible at 595 ms, hero picture shown at 1301 ms, everything loaded at 1301 ms
=== 3. Same page, different fixes (ms)
scenario paint hero load
baseline (HTTP/2) 595 1301 1301
HTTP/1.1, 6 connections per origin 585 1280 1617
preconnect to img, static 595 950 1224
preload hero, font 595 866 1224
preload and preconnect 595 866 1224
repeat visit: css, js, font cached 455 1051 1051
over HTTP/1.1 the img.example requests waited (discovered to sent): hero 190 ms, thumb1 160 ms, thumb2 160 ms, thumb3 160 ms, thumb4 160 ms, thumb5 160 ms, thumb6 171 ms, thumb7 373 ms, thumb8 373 ms
=== 4. Round-trip time stretches a chain of dependent requests (HTTP/2, baseline)
round trip paint hero load critical path length
20 ms 355 897 930 4 requests
80 ms 595 1301 1301 3 requests
200 ms 1075 2136 2136 3 requests
Reading it. All numbers are made up for the lesson. The hero is revealed 310 ms after the HTML finished, and it needs a new connection, so it ends last. Preloading the hero and the font moves their discovery to the end of the HTML and the hero is shown at 866 ms instead of 1301 ms; preconnect alone helps less (950 ms) because the request still starts late. HTTP/1.1 does not change the paint much here but the eight thumbnails queue behind the connection limit, and the load ends later (1617 ms). A repeat visit with the style sheet, script and font cached shows the hero at 1051 ms. A longer round trip stretches everything on the chain: first paint goes from 355 ms to 1075 ms across the three round-trip times.
What the lab does not show. No browser or network. Not modelled: TCP slow start, the priorities browsers assign, HTTP/2 flow control and head-of-line blocking, redirects, service workers, and the preload scanner (real browsers find resources while the HTML is still streaming; the model finds them when it has finished). Render-blocking resources count four times as much when sharing the link, a rule of this lab. The connection limit, round trip, link rate and every size are made up.
Trade-offs
| Fix | Gain | Cost |
|---|---|---|
preload a late resource |
Starts it when the HTML is read | An unused preload downloads a file for nothing, and font needs crossorigin |
preconnect to an origin |
Removes DNS, TCP and TLS from the first request there | Best for only the most critical origins; no benefit on the same origin |
| HTTP/2 | One connection carries many requests | Does not shorten a chain of reveals |
| Fresh cache entry | No network time at all | Needs a correct caching policy |
In practice: a product page whose hero image is late
This is a realistic scenario, not a case history. It is a composite built from common production patterns. It describes no specific company or product, and every number in it is an illustrative assumption.
The situation
A product page paints its text quickly, but the main product photo appears long after. The team has already compressed the photo.
Starting architecture
Figure 4. Starting point: the photo is revealed by a script
How to read this: the photo is the last link of a chain of three, and it needs a new connection.
Options considered
| Option | Fixes | Costs | Risk |
|---|---|---|---|
| Compress the photo further | A shorter download | Quality | The download was not the long part |
| Preload the photo in the HTML | The photo starts when the HTML is read | A hint to keep in step with the real URL | A stale hint downloads a file nobody uses |
| Put the photo in the HTML as an image | No script in the chain | A change to the page code | Needs a layout check |
The decision
| Field | Decision record |
|---|---|
| Context | The waterfall shows the photo revealed by a script, on a new origin, after the HTML. |
| Decision | Name the photo in the HTML, and preconnect to its origin. |
| Consequences, good | The photo no longer waits for the script, and the connection is ready sooner. |
| Consequences, bad | The page code and its template must agree on the photo's address. |
| Revisit when | The photo's URL varies by device, since a hint can only name one. |
Rollout and verification
- Record the waterfall of a cold load before the change, with a throttled connection.
- Ship the change and record it again. The photo's row should start when the HTML finishes.
- Watch the field data (see real user monitoring) before closing the work.
The 2 a.m. failure
A redesign changes the photo's address, and the old preload hint stays in the template. The page now downloads the old file, which nothing uses, while the new photo is again revealed late (illustrative). First three checks: compare the preload's address with the address the page really requests; look for a preloaded file that is downloaded but never used. Mitigation: correct or remove the hint. Follow-up: generate the hint from the same data as the image tag.
Architect's notes
- Fix the chain, not the file. Measure what is on the path to the paint first.
- Prefer removing a hop to hinting around it. A hint is a second copy of an address to keep right.
- Keep the set of critical origins small. Each one costs a connection.
Common mistakes
- Optimising a request that is not on the critical path.
- Preloading something the page may not use.
- Preconnecting to every third party.
- Reading a waterfall once, on a fast connection.
Key takeaways
- A waterfall row has phases: queueing, DNS, connection, waiting, download. Each has its own remedy.
- A request starts when something reveals it; chains of reveals set the paint time.
- Waiting includes a round trip plus server time; a longer round trip stretches the whole chain.
preloadmoves discovery earlier,preconnectmoves connection setup earlier, caching removes network time.- Test a fix by reading the new waterfall, not by trusting the hint.
Practice exercises
Exercise 1 — Starter (30 min): Open the Network panel of any page you own. Find its longest chain by following initiators from the last request back to the document.
Exercise 2 — Intermediate (1 hour): In the lab, add a second hero candidate revealed by the API and decide whether preloading it helps. Predict the result, then run it.
Exercise 3 — Advanced (half day): Add async scripts to the model so a script is not on the critical path, and compare the paint with and without it.
Related reading
In this course:
- HTTP Protocols and Their Trade-offs, what HTTP/1.1, HTTP/2 and HTTP/3 change about connections.
- HTTP Caching, fresh and stale entries behind a repeat visit.
- Preloading, Prefetching and Priority Hints, the hints in depth.
- The Critical Rendering Path, what blocks the first paint.
Official documentation
- Chrome DevTools: Network features reference, the timing phases and the initiator column.
- MDN: rel="preload" and rel="preconnect".
- MDN: PerformanceResourceTiming.
- MDN: HTTP caching.
- RFC 9113: HTTP/2.