Sub topic 3
HTTP Versions, Page Loading, and Rendering
Assume you know basic HTML, CSS, JavaScript, and IP addresses. This chapter connects the HTTP exchange to the page the browser finally draws.
HTTP/1.1, HTTP/2, and HTTP/3 compared
All three versions use HTTP requests and responses, but they transport those messages differently.
| Version | Transport | Main improvement |
|---|---|---|
| HTTP/1.1 | TCP | Simple, persistent connections |
| HTTP/2 | TCP with TLS | Multiplexed streams and compressed headers |
| HTTP/3 | QUIC over UDP | Faster recovery from packet loss |
HTTP/1.1 sends text messages over a TCP connection. A browser can reuse the connection, but requests may compete for it. Browsers often open several connections to improve parallel loading.
HTTP/2 uses one connection for many independent streams. It splits messages into binary frames, so a slow response does not have to block every other response. Header compression also reduces repeated metadata.
HTTP/3 uses QUIC, which includes transport and encryption features. Lost packets in one stream do not block unrelated streams as they can with TCP. The application still uses familiar HTTP methods, status codes, and headers.
Parsing HTML into the DOM
The browser receives HTML bytes and parses them into the Document Object Model (DOM). The DOM is a tree of objects representing elements, attributes, and text. As the parser discovers markup, it can begin finding more resources.
Fetching CSS, scripts, images, and fonts
Each external resource can create another HTTP request. Stylesheets build the CSS Object Model (CSSOM), a tree of parsed CSS rules. Images and fonts usually do not block HTML parsing, but stylesheets can delay painting. Scripts may pause parsing unless they use defer or async.
From DOM and CSSOM to pixels
The browser combines the DOM and CSSOM into a render tree containing visible content. It calculates each object's size and position during layout. It then paints text, colors, borders, and images. Compositing combines layers into the final screen image.
Changing geometry can trigger layout. Changing only a color usually requires paint but not layout. These operations explain why large style changes can make a page feel slow.
Watching it happen with DevTools and curl
In DevTools, open Network, reload the page, and inspect each request. Check its status, protocol, timing, cache state, and initiator. The waterfall shows whether DNS, connection setup, server response, or downloading took the most time.
Use curl to inspect the exchange without rendering the page:
curl -v https://example.com/ -o /dev/nullLook for the negotiated HTTP version, response status, headers, redirects, and timing messages.
Exercise
Why can one HTML response produce many network requests?
Show answer
The HTML can reference stylesheets, scripts, images, fonts, and other resources. The browser fetches those resources separately.