This repository is an attempt to answer the age-old interview question "What happens when you type google.com into your browser's address box and press enter?"
Except instead of the usual story, we're going to try to answer this question in as much detail as possible. No skipping out on anything.
This is a collaborative process, so dig in and try to help out! There are tons of details missing, just waiting for you to add them! So send us a pull request, please!
This is all licensed under the terms of the Creative Commons Zero license.
Read this in 简体中文 (simplified Chinese), 日本語 (Japanese), 한국어 (Korean) and Spanish. NOTE: these have not been reviewed by the alex/what-happens-when maintainers.
- The "g" key is pressed
- The "enter" key bottoms out
- Interrupt fires [NOT for USB keyboards]
- (On Windows) A
WM_KEYDOWNmessage is sent to the app - (On OS X) A
KeyDownNSEvent is sent to the app - (On GNU/Linux) the Xorg server listens for keycodes
- Parse URL
- Is it a URL or a search term?
- Convert non-ASCII Unicode characters in the hostname
- Check HSTS list
- DNS lookup
- ARP process
- Opening of a socket
- TLS handshake
- If a packet is dropped
- HTTP protocol
- HTTP Server Request Handle
- Behind the scenes of the Browser
- Browser
- HTML parsing
- CSS interpretation
- Page Rendering
- GPU Rendering
- Window Server
- Post-rendering and user-induced execution
The following sections explain the physical keyboard actions and the OS interrupts. When you press the key "g" the browser receives the event and the auto-complete functions kick in. 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 dropdown below the URL bar. Most of these algorithms sort and prioritize results based on search history, bookmarks, cookies, and popular searches from the internet as a whole. As you are typing "google.com" many blocks of code run and the suggestions will be refined with each keypress. It may even suggest "google.com" before you finish typing it.