How Browsers Load a Web Page
How Browsers Load a Web Page
Understanding how a browser loads a web page is essential for anyone who works with websites—developers, designers, and even content creators.
When you understand this workflow, you can optimize performance, fix rendering delays, and improve user experience and Core Web Vitals.
1. Step 1 — URL Input & DNS Lookup
The browser loading journey begins the moment a user types a URL like:
1.1 What happens next?
-
The browser checks its internal cache for a DNS record.
-
If not found, it queries the operating system DNS cache.
-
If still not found, the OS sends a request to a DNS resolver.
-
The resolver returns the IP address (e.g.,
93.184.216.34) of the server hosting the website.
1.2 Why it matters
-
DNS lookup adds latency.
-
Slow DNS affects Time to First Byte (TTFB).
2. Step 2 — Establishing a TCP & TLS Connection
2.1 TCP Handshake
After DNS lookup, the browser must establish a connection using the TCP 3-way handshake:
-
SYN
-
SYN-ACK
-
ACK
Only after this handshake can data start flowing.
2.2 TLS Handshake (If HTTPS)
For secure sites:
-
Browser verifies SSL certificate
-
Negotiates encryption algorithms
-
Establishes a secure session
2.3 Example: HTTPS Request Timeline
2.4 Optimization Tips
-
Use HTTP/2 or HTTP/3
-
Enable TLS 1.3
-
Use CDN for lower latency
-
Use OCSP stapling for faster certificate checks
3. Step 3 — Sending the HTTP Request
Once the connection is ready, the browser sends a request:
The server receives this and returns a response.
Response Includes
-
Status code (200 OK)
-
Headers (cache-control, content-type)
-
Body (HTML content)
4. Step 4 — Browser Receives HTML & Starts Parsing
The browser does not wait for the entire HTML file to download.
It begins parsing immediately, generating a DOM (Document Object Model).
4.1 DOM Example
HTML:
DOM Tree:
4.2 Why DOM Creation Matters
-
JavaScript can block DOM creation
-
CSS might delay rendering
-
Improper script placement slows page load
5. Step 5 — Resource Discovery (CSS, JS, Images)
While parsing HTML, the browser discovers external resources:
Example:
As soon as the browser sees these tags, it queues download requests.
5.1 Blocking Behavior
-
CSS is render-blocking
-
JS is parser-blocking (unless async/defer)
5.2 JavaScript
Use:
or
5.3 CSS
Use media attributes:
5.4 Preload critical assets
6. Step 6 — Downloading Resources
The browser uses multiple parallel connections to fetch assets.
6.1 With HTTP/1.1
-
Limited parallel requests
-
Combining files is beneficial
6.2 With HTTP/2 & HTTP/3
-
Multiplexing allows faster parallel downloads
-
Minify CSS/JS, but merging is optional
6.3 Caching
If a resource is cached, the browser may not download it.
Example cache header:
7. Step 7 — Building the CSSOM (CSS Object Model)
Once CSS files download, the browser parses them to build the CSSOM.
Example CSS:
CSSOM Tree:
Why CSSOM is Important
Rendering cannot happen until:
-
DOM is ready
-
CSSOM is ready
Together, they form the Render Tree.
8. Step 8 — Blocking JavaScript Execution
JavaScript affects page rendering because it can modify the DOM and CSSOM.
8.1 Blocking Example
This stops HTML parsing until the JS file:
-
Downloads
-
Parses
-
Executes
8.2 Avoid This Using defer
8.3 Avoid This Using async
9. Step 9 — Constructing the Render Tree
The Render Tree merges:
-
DOM
-
CSSOM
This tree represents what will actually be displayed.
Example:
HTML:
CSS:
Render Tree:
10. Step 10 — Layout (Reflow)
During layout, the browser calculates:
-
Positions
-
Sizes
-
Margins
-
Padding
-
Z-index
Example:
Browsers compute the exact pixel values.
10.1 Layout is expensive
-
DOM changes trigger reflows
-
Nested elements multiply cost
10.2 Optimization Tip
Batch DOM edits:
Bad:
Good:
11. Step 11 — Painting
Once layout is done, the browser paints:
-
Colors
-
Borders
-
Text
-
Shadows
-
Images
This step converts the render tree into pixels.
12. Step 12 — Compositing
If layers exist (transforms, fixed elements, animations), the browser composites them into the final display.
Example triggers new layers:
Compositing helps:
-
Smooth animations
-
Faster rendering
13. Complete Browser Rendering Flow (Diagram)
Here is a simplified diagram you can reuse in your article:
14. Real-World Example of the Entire Process
User visits: https://shop.example.com
Behind the scenes:
-
Browser performs DNS lookup
-
Browser establishes HTTPS connection
-
Sends GET request
-
Receives HTML
-
Starts parsing
-
Encounters
<link rel="stylesheet"> -
Downloads CSS (blocks render)
-
Encounters
<script> -
Pauses parsing (unless deferred)
-
Builds DOM & CSSOM
-
Creates render tree
-
Calculates layout
-
Paints page
-
Composites header, sidebar, and modal layers
The user sees the complete page in under 1 second with optimization.
15. Tips to Optimize Every Stage
15.1 Before HTML Loads
-
Use fast DNS
-
Use CDN
-
Enable HTTP/3
15.2 During HTML Parsing
-
Minify HTML
-
Avoid inline JS blocking
15.3 CSS Phase
-
Inline critical CSS
-
Use media queries (
media="print") -
Use
preloadfor important assets
15.4 JS Phase
-
Use
deferfor scripts -
Avoid manipulating DOM repeatedly
-
Lazy-load heavy libraries
15.5 Layout & Paint
-
Avoid overly complex nesting
-
Prefer CSS transformations over layout-changing animations
-
Combine layers wisely
16. Checklist for Developers
Performance Checklist
-
Use HTTP/2 or HTTP/3
-
Enable Brotli compression
-
Use
<script defer> -
Inline above-the-fold CSS
-
Use CDN for assets
-
Optimize images (WebP recommended)
-
Remove unused CSS with PurgeCSS
-
Minify HTML/CSS/JS
17. Conclusion
Every time a user opens a web page, the browser performs dozens of actions—DNS resolution, TLS handshake, parsing HTML, downloading resources, building DOM and CSSOM, layout, painting, and compositing.
When you understand these stages, you can dramatically improve your site's performance.





