Skip to content

    Frontend System Design

    Reading a Network Waterfall: Putting Web Fundamentals to Work

    Read a network waterfall as a chain of dependent requests, find what delays the paint, and test fixes such as preload, preconnect and caching on a small model.

    By Published 8 min read

    Share

    Focused lessonintermediateInteractive simulatorFrontend System Design

    Before this: HTTP/1.1, HTTP/2 and HTTP/3 for Front-End Engineers, HTTP Caching for the Front End

    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

    1. 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.
    2. Each request pays for connection, waiting and download separately. Different slowness needs different fixes.
    3. 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

    sequenceDiagram accTitle: The phases of one request to a new origin accDescr: For a new origin the browser first resolves the name with DNS, then opens a TCP connection, then negotiates TLS. Only then is the request sent. The server takes some time to prepare the response, the first byte arrives, and the body downloads. A second request to the same origin skips the first three steps. participant B as Browser participant D as DNS participant S as Server B->>D: look up the origin D-->>B: address B->>S: TCP handshake B->>S: TLS negotiation B->>S: request Note over B,S: waiting: one round trip plus server time S-->>B: first byte, then the body Note over B,S: the next request to this origin skips the setup

    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

    The HTML reveals a script, and the script reveals the hero image on another origin and an API callHTML to Script (reveals); Script to Hero image (reveals); Script to API call (reveals)HTML: app originHTMLapp originScript: app originScriptapp originHero image: image originHero imageimage originAPI call: app originAPI callapp originrevealsrevealsreveals

    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

    flowchart TD accTitle: Choosing a fix from a slow waterfall row accDescr: Look at the slow request. If it starts late, find what revealed it and consider a preload hint or removing a hop. If it waits before the connection, consider preconnect or fewer origins, and check the connection limit on HTTP/1.1. If the wait for the first byte is long, look at the server and the round trip. If the download is long, look at the size and whether other downloads share the link. Q{"What is long
    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.

    1. Run the tests and the demo. In section 1, find the dotted stretch before hero and before thumb1: they wait on a connection.
    2. In section 2, follow hero up to app.js and then doc. That is the critical path.
    3. In section 3, compare "preload hero, font" with the baseline, then with "repeat visit".
    4. 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

    NOTE

    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

    Starting architecture: the product photo is added by a script that is itself fetched after the HTMLHTML to App script (reveals); App script to Photo (reveals late)HTML: product pageHTMLproduct pageApp script: adds the photoApp scriptadds the photoPhoto: other originPhotoother originrevealsreveals late

    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

    1. Record the waterfall of a cold load before the change, with a throttled connection.
    2. Ship the change and record it again. The photo's row should start when the HTML finishes.
    3. 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.
    • preload moves discovery earlier, preconnect moves 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.

    In this course:

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments