How Web Browsers Work

Understanding the internal working mechanism of web browsers, from DNS lookup to page rendering.

Featured image



🎯 Overview

Let’s explore how web browsers work internally, from the moment a user enters a URL until the page is displayed.

📝 Summary

  1. User accesses website through browser (www.a.com)
  2. Browser identifies server’s IP address through DNS
  3. Browser and server perform 3-Way Handshake
  4. Browser sends HTTP Request to server
  5. Server sends HTTP Response to browser
  6. Browser parses HTML to create DOM Tree
  7. Upon encountering Style tags, pauses DOM creation to parse CSS and create CSSOM Tree
  8. When encountering script tags, passes control to JavaScript engine to parse and create AST
  9. Creates Render Tree by combining DOM + CSSOM
  10. This process is called Construction
  11. Rendering engine performs Layout on Render Tree nodes
  12. UI backend draws UI by traversing Render Tree nodes (Painting)
  13. Finally, composes nodes in Render Tree in order (Composition)
  14. This process is called Operation
  15. Displays final result to web user



📊 Web Browser Working Process Flow Chart

graph TD; A[🌐 User accesses website www.a.com] --> B[📡 DNS Lookup: Resolve IP address]; B --> C[🔗 3-Way Handshake SYN → SYN/ACK → ACK]; C --> D[📨 Send HTTP Request to Server]; D --> E[📥 Receive HTTP Response]; E --> F[🛠️ Parse HTML → Create DOM Tree]; F --> G{🎨 Style tag detected?}; G -- Yes --> H[🖌️ Parse CSS → Create CSSOM Tree]; H --> F; G -- No --> I{📜 Script tag detected?}; I -- Yes --> J[⚙️ Parse JavaScript → Create AST]; J --> F; I -- No --> K[📝 Merge DOM + CSSOM → Render Tree]; K --> L[📐 Layout: Position Elements]; L --> M[🖼️ Painting: Render UI]; M --> N[📊 Composition: Organize Layers z-index]; N --> O[👀 Display Rendered Page to User]; %% Additional Explanation E -.-> P[⚡ Partial Rendering for Faster Display]; P --> F;



🔍 Detailed Process

🏗️ Construction Phase

🎨 Operation Phase



⚠️ Additional Notes

The parsing, layout, and UI drawing processes don’t wait for all data to be received from the server. For faster user experience:

🔑 Key Points

  1. CSS is a render-blocking resource, not a parsing-blocking resource
  2. JavaScript execution blocks parsing
  3. Progressive rendering improves perceived performance



📚 Reference