-------------------------[ The web in 1000 lines of C ]------------------------- Publication date: 2026-03-12 Modern browsers are hugely complex: Chromium (the open source portion of google chrome) currently has 49 millions lines of code, making it bigger then any other program on my machine. ... but how much of that is needed if I just want to visit websites instead of running multi-gigabyte Javascript abominations that just happen to render to the browser? My goal is to to read all the blogs on my link list: The pages have to be rendered (no printing HTML) and links must work. Let's start by trying to view the list. Here's the URL: http://maurycyz.com/real_pages/ The http in the URL tells use that the server is expecting plaintext (unencrypted) HTTP. After connecting to the server, the browser has to send an HTTP request: GET /real_pages/ HTTP/1.0 User-Agent: MyEpicBrowser/1.0 Host: maurycyz.com [trailing blank line] Repeating the hostname in the request might seem redundant, but it's very common to host multiple websites on one IP address. (Cloudflare, etc) Assuming everything goes well, the server will respond with some metadata, a blank line, and the page: HTTP/1.0 200 OK Content-Length: 14 Content-Type: text/plain Hello, World! URLs don't usually include an IP address, so the browser has to perform a DNS lookup before connecting. I used the C library for this, which I don't consider cheating because DNS is very widely used outside of the web. So now the browser has the page, but it's not exactly something that can be displayed. Most pages look something like this: Shining light on photodiodes - lcamtuf’s thing ... a few hundred of these ... ... and a few thousand lines more Where's the content? It's all mashed into line 206, starting at column 4097. On paper, parsing HTML is easy, but there is a huge amount of edge cases. For example, this is perfectly valid html:

I made a website.

These are some cool things

... and so is ...