> For the complete documentation index, see [llms.txt](https://notes.mikaelsamvelian.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.mikaelsamvelian.com/linux-fundamentals/networking/browser-url-example.md).

# Browser URL Example

What happens when you start typing google in your browser's search bar?&#x20;

<https://github.com/alex/what-happens-when>

### Simplified

#### Keyboard Actions

* **Key Pressed**: "g" key pressed; browser processes it and suggests URLs based on history.
* **Enter Key**: Physical keypress leads to electrical signals transmitted to the computer.
  * USB keyboard: Current flows to logic circuitry, keycode is generated and sent.
  * Virtual keyboard: Capacitive touch registers keypress, sends a software interrupt.

#### OS-Level Events

* **Interrupts**:
  * OS detects the keypress and triggers an interrupt request.
  * **Windows**: Sends a `WM_KEYDOWN` message.
  * **macOS**: Sends an `NSEvent`.
  * **Linux**: Xorg server listens for keycodes.

#### URL Parsing

* **URL or Search Term**: Determines if the input is a URL or search term.
* **Non-ASCII Characters**: Converts characters using Punycode if needed.

#### Network Communication

* **DNS Lookup**:&#x20;
  * If the browser doesn't find the domain in its local cache, it sends a request to the DNS server (usually provided by the ISP or a local router).
  * If the DNS server doesn't have the answer, it will act as a recursive resolver, querying other DNS servers higher up in the hierarchy on behalf of the client.

<figure><img src="/files/CFIyknl7GSIjhhRyJteM" alt=""><figcaption></figcaption></figure>

* **ARP Process**: Determines the MAC address for the DNS server or default gateway.
* **Socket Opening**: Establishes a connection to the server using TCP.
* **TLS Handshake**: Encrypts communication using SSL/TLS for HTTPS.

#### HTTP Protocol

* **Request**: Sends an HTTP request to the server (e.g., GET request).
* **Response**: Server returns HTML, possibly with a status code (e.g., `200 OK`).
* **Resources**: Browser fetches additional resources (images, CSS) as needed.

#### Browser Rendering

* **HTML Parsing**: Parses the HTML document into a DOM tree.
* **CSS Parsing**: Interprets CSS to apply styles.
* **Rendering**: Constructs a render tree, lays out elements, and paints them on the screen.
* **GPU Rendering**: Uses GPU for faster rendering in modern browsers.

#### Post-Rendering

* **JavaScript Execution**: Runs any JavaScript on the page.
* **User Interaction**: Scripts and network requests can be triggered by user input.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.mikaelsamvelian.com/linux-fundamentals/networking/browser-url-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
