What happens when you type a URL and press Enter?
- URL parsing: the browser decides whether it is a URL or a search, and checks the HSTS list to force HTTPS.
- Cache check: a service worker or the HTTP cache may answer immediately.
- DNS lookup: browser cache, OS cache, then a resolver turns the host into an IP address.
- Connection: TCP handshake plus TLS handshake (TLS 1.3 needs one round trip), or a single QUIC handshake for HTTP/3. ALPN agrees on HTTP/2 or HTTP/3.
- HTTP request with headers and cookies; the server (often a CDN edge) responds with status, headers and HTML.
- Parsing HTML into the DOM. The preload scanner spots CSS, scripts, images and fonts early and starts downloading them.
- CSS is parsed into the CSSOM. CSS is render-blocking: nothing paints until it is loaded.
- JavaScript: a classic
<script>blocks parsing while it downloads and runs;deferruns after parsing in order;asyncruns as soon as it arrives; modules are deferred by default. - Render tree: DOM + CSSOM, visible nodes only.
- Layout (reflow) computes positions and sizes, paint fills pixels into layers, and composite combines the layers on the GPU.
- The
DOMContentLoadedandloadevents fire; the page becomes interactive once the main thread is free.
Where frontend engineers can help
Fewer round trips (CDN, HTTP/2 or 3, preconnect), less render-blocking CSS and JavaScript, smaller payloads, and caching.
Example
html
<head>
<link rel="preconnect" href="https://api.example.com" crossorigin />
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin />
<link rel="stylesheet" href="/app.css" /> <!-- render-blocking: keep it small -->
<script src="/app.js" type="module"></script> <!-- deferred automatically -->
<script src="https://analytics.example.com/a.js" async></script>
</head>Follow-up questions interviewers ask
Try answering each one before you open it.
What is the critical rendering path and how do you shorten it?
It is the sequence of steps from receiving HTML to the first pixels: HTML → DOM, CSS → CSSOM, render tree, layout, paint. Shorten it by inlining critical CSS for above-the-fold content, deferring the rest, using defer/async/modules for scripts, reducing the number and size of critical resources, and server rendering the main content.