# Build a working web browser from scratch in a few thousand lines of Python

Original title: Web Browser Engineering

> Hacker News story 50537290 · language: en · submitted 2026-11-17
> Web version: https://zeli.app/story/50537290
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 194 · by [ibobev](<https://news.ycombinator.com/user?id=ibobev>) · 💬 29
[original](<https://browser.engineering/>) · [HN discussion](<https://news.ycombinator.com/item?id=50537290>)

## Summary

Pavel Panchekha and Chris Harrelson's Web Browser Engineering is a free online book that walks you through constructing a basic but complete browser in a couple thousand lines of Python. It covers networking and HTTP, HTML parsing, CSS layout, JavaScript-driven interactivity, cookies and XSS/CSRF defenses, plus modern topics like GPU compositing, the event loop, accessibility, and invalidation.

## Key quote

> Web browsers are ubiquitous, but how do they work? This book explains, building a basic but complete web browser, from networking to JavaScript, in a couple thousand lines of Python.

## HN discussion (29 comments)

### [pavpanchekha](<https://news.ycombinator.com/item?id=50537943>)

> Hi folks, one of the authors here. Happy to answer questions. Chris and I wrote the book starting in 2019, and the book was largely done in late 2024, with publication in 2025. In case folks are wondering, literally none of it was AI-written, because the AIs didn't exist yet!

### [coreyp_1](<https://news.ycombinator.com/item?id=50539181>)

> Nice.
>
> I'm on the path to building a browser.  I had vaguely remembered this site from when it was listed before, but I couldn't find it when looking again.  It's bookmarked now. :)
>
> I'm writing my own libraries (because, with AI, why not indulge in low-level fun?), and I'm almost to the layout engine.
>
> So far (all C libraries), I can read multiple image formats, parse HTML/XML and CSS, rasterize text and just about anything that can be required by CSS or SVG.  Fonts were fun... I can do TTF but not WOFF yet.  I can do some WASM, but no JS engine yet.  I do have my Regex engine, though.  (I had built WASM first because it's being used for another project).  Still a long way to go.  Only approx 780K lines spread out across 30 or so libraries written so far.

### [kuharich](<https://news.ycombinator.com/item?id=50539364>)

> Past comments: https://news.ycombinator.com/item?id=26707368, https://news.ycombinator.com/item?id=28898157, https://news.ycombinator.com/item?id=41846780

---

## Cite

- Page: https://zeli.app/story/50537290
- Date: 2026-11-17
- Source: browser.engineering (https://browser.engineering/)
- Hacker News: https://news.ycombinator.com/item?id=50537290

## Other languages

- zh: https://zeli.app/zh/story/50537290 · markdown: https://zeli.app/zh/story/50537290.md
- ja: https://zeli.app/ja/story/50537290 · markdown: https://zeli.app/ja/story/50537290.md
- ko: https://zeli.app/ko/story/50537290 · markdown: https://zeli.app/ko/story/50537290.md
- de: https://zeli.app/de/story/50537290 · markdown: https://zeli.app/de/story/50537290.md
- es: https://zeli.app/es/story/50537290 · markdown: https://zeli.app/es/story/50537290.md
- ru: https://zeli.app/ru/story/50537290 · markdown: https://zeli.app/ru/story/50537290.md
