This section is for some developers who already know what a browser is but want to understand the internals, how it works under the hood, what its architecture looks like, and how different engines (Chromium, WebKit, Gecko) work and differ. We’ll also touch code, concepts, and components.
Definition and Purpose
A web browser is a client-side software application that fetches, interprets, and displays web content served over the internet. It primarily uses HTTP/HTTPS protocols to communicate with web servers and render HTML, CSS, JavaScript, images, and other assets on the screen. At its core, the browser makes network requests (such as GET and POST), parses code written in HTML, XML, CSS, or JavaScript, builds a DOM and render tree, paints the interface, and handles user input and interactivity.
At its core, the browser:
- Makes network requests (GET, POST, etc.)
- Parses code (HTML/XML/CSS/JS)
- Builds a DOM and render tree
- Paints the interface
- Handles user input and interactivity
Core Architecture of a Browser
Most modern browsers are structured using a multi-process or multi-threaded architecture for both performance and security. The User Interface (UI) encompasses components like the address bar, navigation buttons, bookmarks, and tab management. The Browser Engine acts as a mediator between the UI and the Rendering Engine, instructing the latter on how to behave and update.
The Rendering Engine is responsible for parsing HTML and CSS to construct the DOM and CSSOM, which are then merged into a render tree. This tree undergoes layout calculations and is painted onto the screen, followed by compositing. The Networking module handles HTTP/HTTPS requests, caching, proxy settings, and cookie management. The JavaScript Engine (like V8 or SpiderMonkey) parses, compiles, and executes JavaScript, managing asynchronous tasks using an event loop and callback queue.
Data Storage is managed through technologies like Web Storage (localStorage and sessionStorage), IndexedDB, the Cache API, and traditional cookies. Lastly, browsers contain essential Security Components such as sandboxing, Same-Origin Policy enforcement, CORS (Cross-Origin Resource Sharing), and Content Security Policy (CSP) mechanisms.
Source: by Kishan Vikani at Stack Overflow
Rendering Engine
The DOM (Document Object Model) represents the HTML structure as a tree of elements, while the CSSOM (CSS Object Model) captures styles and rules in a similar tree. Combined, these models create a render tree used for visual representation.
In the Layout and Paint process, each node's position and size is computed, which is known as layout or reflow. The browser then paints the visual elements onto layers and finally performs compositing to merge these layers for display.
Popular Browser Engines
Chromium / Blink (Used by Chrome, Edge, Opera, Vivaldi, Brave,...)
Chromium is an open-source base developed by Google. Blink, a fork of WebKit, is its rendering engine. Chromium uses the V8 JavaScript engine and has a highly modular architecture, supporting sandboxing and a multi-process design. The rendering lifecycle involves parsing JavaScript in V8 and executing code like:
Its architecture includes a UI process for tab and window management, a renderer process for each tab, and a GPU process to handle compositing.