Agent Wranglers

Performance

How to make a page load about as fast as the network allows. The speed rules for any site, what moved the numbers in practice, and what to skip.

  • Required 5
  • Recommended 12
  • Optional 5
  • Avoid 1

Required

Optional

Avoid

Reaching the network floor

A new visitor's page can't arrive sooner than three round trips. They are the TCP handshake, the TLS 1.3 handshake and the request itself. That is the network floor. The main image needs at least one more. A fast page gets as close to that floor as it can:

  1. Fit the first send. Keep the compressed HTML small (10 to 15 KB) and raise the initial congestion window, so the page arrives in one go.
  2. Make first paint depend on nothing else. Inline the CSS, keep scripts deferred, and don't preload fonts. First paint then follows the HTML by the time it takes to read and draw it. On a reference site that was about 40 to 55 ms.
  3. Start the main image at once. Put it early in the HTML with fetchpriority="high" and a size that fits the screen, so it arrives one round trip after the HTML.
  4. Make clicks free. Prefetch on hover or touch, fill a service worker cache with the page's links after load, and skip page-transition animations.

After that, only protocol features that skip handshakes can help. TLS 1.3 resumption with 0-RTT needs an earlier visit. HTTP/3 saves the TCP handshake, but on a first visit only with an HTTPS DNS record.

Distance from the floor

An earlier lab server with HTTPS, HTTP/2 and initcwnd 32, at three round-trip times. Floor = TCP + TLS 1.3 + HTML = 3 round trips. A separate main image adds one. Times in ms, phone 3× / desktop 2×.

Round tripHTML, separate image (inlined image)Image shown, separateImage shown, inlined4-round-trip floor
1239 (51)90 / 8678 / 8648
50153 (203)222 / 222230 / 238200
100303 (403)418 / 422430 / 438400

Tried and rejected

OptionWhy not
Inlining the main imageSlower from a 50 ms round trip up (table above).
HTTP/3 for first visitsBrowsers switch after seeing Alt-Svc, so a first visit gains nothing without an HTTPS DNS record. Older servers, such as nginx before 1.25, have no HTTP/3.
tcp_slow_start_after_idle off, BBRHelp repeat or long connections, not a first visit.
Autoplaying animationsCost work on phones and break reduced-motion expectations. Start them on a click.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/performance.