vasanthk /how-web-works

What happens behind the scenes when we type www.google.com in a browser?

★ 16,770⑂ 1,742👁 203⑃ 13● 19▤ 0
Created 2015-10-17
More from this author
+0
Daily
16,770
stars
1,742
forks
203
watchers
13
prs
19
issues
0
releases

README

How Web Works

What happens behind the scenes when we type google.com in a browser?

Table of Contents

- Google's 'g' key is pressed
- When you hit 'Enter'
- Parse the URL
- Check HSTS list (deprecated)
- DNS lookup
- Opening of a socket + TLS handshake
- HTTP protocol
- HTTP Server Request Handle
- Server Response
- Behind the scenes of the Browser
- The browser's high level structure
- Rendering Engine
- The Main flow
- Parsing Basics
- DOM Tree
  - Why is the DOM slow?
- Render Tree
- Render tree's relation to the DOM tree
- CSS Parsing
- Layout
- Painting
- Trivia
  - The birth of the web

 Google's 'g' key is pressed

When you just press "g", the browser receives the event and the entire auto-complete machinery kicks into high gear. Depending on your browser's algorithm and if you are in private/incognito mode or not various suggestions will be presented to you in the dropbox below the URL bar. Most of these algorithms prioritize results based on search history and bookmarks. You are going to type "google.com" so none of it matters, but a lot of code will run before you get there and the suggestions will be refined with each key press. It may even suggest "google.com" before you type it.

 When you hit 'Enter'

To pick a zero point, let's choose the Enter key on the keyboard hitting the bottom of its range. At this point, an electrical circuit specific to the enter key is closed (either directly or capacitively). This allows a small amount of current to flow into the logic circuitry of the keyboard, which scans the state of each key switch, debounces the electrical noise of the rapid intermittent closure of the switch, and converts it to a keycode integer, in this case 13. The keyboard controller then encodes the keycode for transport to the computer. This is now almost universally over a Universal Serial Bus (USB) or Bluetooth connection.

In the case of the USB keyboard:
 The keycode generated is stored by internal keyboard circuitry memory in a register called "endpoint".
 The host USB controller polls that "endpoint" every ~10ms, so it gets the keycode value stored on it.
 This value goes to the USB SIE (Serial Interface Engine) sent at a maximum speed of 1.5 Mb/s (USB 2.0).
 This serial signal is then decoded at the computer's host USB controller, and interpreted by the computer's Human Interface Device (HID) universal keyboard device driver.
 The value of the key is then passed into the operating system's hardware abstraction layer.

In the case of touch screen keyboards:
 When the user puts their finger on a modern capacitive touch screen, a tiny amount of current gets transferred to the finger. This completes the circuit through the electrostatic field of the conductive layer and creates a voltage drop at that point on the screen. The screen controller then raises an interrupt reporting the coordinate of the 'click'.
 Then the mobile OS notifies the current focused application of a click event in one of its GUI elements (which now i

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON