What a browser does
When you enter a URL, the browser coordinates network, security, document analysis and rendering.
From URL to response
- It analyzes the URL: protocol, domain, port, path and parameters.
- It searches for the IP address of the domain using DNS.
- It establishes a secure connection for HTTPS.
- It sends an HTTP request.
- It receives a status code, headers and content.
Connections can be reused. With HTTP/2 or HTTP/3, several exchanges can share the same connection; so she is not systematically closed after each resource.
From response to pixels
- the HTML becomes a DOM;
- the CSS becomes a CSSOM;
- the browser combines the information necessary for rendering;
- it calculates the geometry of the elements (layout);
- he paints then composes the different layers;
- JavaScript can modify the document and trigger new calculations.
HTML → DOM ─┐
├→ arbre de rendu → layout → paint → composition
CSS → CSSOM┘
The role of JavaScript
JavaScript can listen to interactions, modify the DOM, read some APIs of the browser and make new requests. A long JavaScript task may, however, temporarily block display and interactions.
Quick challenge
Open developer tools, reload a page and choose its query Main HTML. Find its HTTP code, content type and duration, then identify a resource then loaded by the browser.