Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

How a Web Page Loads

Follow a request from the address bar to pixels on screen: DNS, connection, TLS, response, parsing, subresources and rendering, and see where time is lost.

When you press Enter on a URL, a long chain of steps runs before you see anything. Each step can be slow, and each has its own fix. If you know the chain, you can look at a slow page and say which link is the problem instead of guessing.

This lesson walks through the whole journey, from the address bar to the first pixels, and shows how to read it with the browser's Navigation Timing data.

The journey in order

flowchart LR
  A["Redirects"] --> B["DNS lookup"]
  B --> C["TCP connection"]
  C --> D["TLS handshake"]
  D --> E["Request sent"]
  E --> F["Server thinks (TTFB)"]
  F --> G["HTML downloads"]
  G --> H["Parse and render"]

Every page load starts with this network chain before rendering begins.

  1. Redirects. http:// to https://, or example.com to www.example.com. Each redirect is a whole extra round trip.
  2. DNS lookup. The browser turns a hostname into an IP address. Cached answers are nearly free; a cold lookup can take tens or hundreds of milliseconds.
  3. TCP connection. A handshake opens a channel to the server. It costs one round trip. (HTTP/3 uses QUIC instead, which is faster to start.)
  4. TLS handshake. For https, client and server agree on encryption. This costs one or two more round trips on older protocol versions.
  5. Request and server time. The browser sends GET /. The server builds the response. The wait until the first byte comes back is the Time to First Byte (TTFB).
  6. Download. The HTML streams in. Browsers start parsing before the download finishes.

A round trip is limited by the speed of light and the distance to the server. You cannot make a request to another continent faster than physics allows, but you can move your content closer with a CDN (see CDN and edge caching).

After the HTML arrives

The browser reads the HTML from top to bottom and builds the DOM (the tree of elements). Whenever it sees a reference to another file, it plans a request:

Found in HTML What happens
<link rel="stylesheet"> Download CSS; blocks rendering until it is ready
<script src> (no async/defer) Pauses parsing, downloads and runs the script
<script defer> Downloads in parallel, runs after parsing, in order
<script async> Downloads in parallel, runs as soon as it arrives
<img> Downloads in parallel; does not block rendering
<link rel="preload"> High-priority early fetch

Once CSS is ready, the browser builds the CSSOM, combines it with the DOM into a render tree, works out sizes and positions (layout), and draws the result (paint and composite). The next lesson, how browsers render a page, goes deep on this part.

Read the timeline yourself

The browser records each phase of the navigation. Here is a tiny script that prints the durations it can see. The numbers vary on every run, so the demo prints only facts that are always true.

Navigation Timing phases

On a real site you would send these numbers to your analytics. The pattern is always: subtract the start of a phase from its end.

Subresources and the waterfall

A page rarely is only one file. A typical page loads dozens of CSS, JS, image and font files. Browsers open several connections, request many files at once and give each a priority. Tools show this as a waterfall chart: one bar per file, with time running left to right.

Read a waterfall for these signs:

  • A long first bar means slow DNS, connection or TTFB.
  • A staircase means files are discovered late, because one file has to load before the browser learns about the next (for example a font referenced from a CSS file).
  • Wide blocks of download time mean large files.
  • Gaps mean the main thread or network was idle, waiting.
List resources the page loaded

performance.getEntriesByType("resource") lists every subresource with its timing and size fields. It is the raw material of every waterfall chart.

Where time is usually lost

Most slow pages have one of a few causes: a slow server, a chain of redirects, too many or too large files, render-blocking CSS and JavaScript, or late discovery of important files. The rest of the course attacks each in turn.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does TTFB measure?

    Time to First Byte covers the request, server processing and the first bytes travelling back.
  2. 2. Which script attribute downloads in parallel and runs after the document is parsed, in order?

    defer keeps scripts in document order and runs them after parsing. async runs each as soon as it arrives.
  3. 3. A staircase pattern in a waterfall most likely means

    Each file only reveals the next one after it loads, creating a chain of dependent requests.
  4. 4. Why does each redirect hurt performance?

    The browser must request the new URL and wait again before it can start the real request.

Summary

  • A load goes: redirects, DNS, TCP, TLS, request, server time, download, parse, render.
  • Each network step costs round trips, so fewer and closer is faster.
  • Scripts and stylesheets can block parsing or rendering unless you use defer, async or smarter loading.
  • The Performance API and waterfall charts show where time went.

Next: How Browsers Render a Page