Home / Blog

What it takes to keep a web browser under 60 MB

Notes from Broxee's budget log, on making DOM nodes smaller, skipping CSS rules a page can't use, and finding memory the allocator was holding on to.

Pandhu Wibowo November 15, 2026 4 min read

Broxee is a browser we're building in Labs with one rule: the app has to stay under 60 MB, on disk and in memory. The rule is enforced by a script, not by good intentions. It builds the release binary, generates a stress page of 20,000 rows, lays it out and paints it at 2x (a Retina frame), and fails if the binary or the peak memory reaches 60 MB.

Every change that touches parsing, layout or painting gets a line in the project's budget log, with its numbers. Most of what follows comes straight from that log. These are the changes that moved the numbers most.

The DOM was twice as big as it needed to be

The first DOM was the obvious one: each element held a Vec of children and owned its strings. On the 2.6 MB stress page it peaked at 55.8 MB, before any styling or layout. That alone would have used up the whole budget.

The next version changed four things at once:

Peak memory on the same page dropped to 27.0 MB. A later pass shrank each node to 28 bytes and moved text and attribute values into shared buffers. The lesson repeated through the whole project: the first data structure you reach for is usually the one that costs the most.

Most of a site's CSS doesn't apply to the page you're on

Sites ship one stylesheet for all their pages. GitHub's home page loads 30,309 CSS rules. Parsing and matching every one of them is a lot of work and a lot of memory for rules that can never match.

So before Broxee parses a stylesheet, it collects every tag, id and class that actually appears in the document. A rule whose selectors all need a name the page doesn't have is skipped without parsing its declarations. On GitHub, 28,170 of the 30,309 rules are skipped. Memory for that page fell from 43.7 MB to 25.3 MB before painting, and from 60.2 MB to 40.5 MB painted at 2x.

We checked that this changes nothing you can see: computed styles on GitHub, Wikipedia, Hacker News and MDN were compared node by node with and without the shortcut, and they were identical.

The allocator was keeping memory we'd already freed

This one took the longest to find. After visiting GitHub and then example.com, the macOS heap tool counted only 6.8 MB of live allocations, yet the process held 19 to 25 MB more in small-allocation regions. Those were blocks Broxee had freed, which macOS malloc kept in its per-CPU caches.

Asking the allocator to give pages back (malloc_zone_pressure_relief) changed nothing. Starting the process with MallocSpaceEfficient=1 did. For the same sequence, idle memory went from 43 to 29 MB and the peak from 59 to 48 MB, with parse, cascade, layout and paint times unchanged across three runs.

libmalloc reads that variable only when a process starts, so Broxee restarts itself once with it set, which takes about 10 ms. It isn't documented in man malloc. If a future macOS ignores it, memory goes back to the old numbers and nothing else breaks, which is the kind of failure we can live with.

Tabs that don't live in memory

A browser that keeps every tab loaded can't stay under 60 MB. In Broxee only the visible tab is a live page. The others sleep: the HTML and stylesheets exactly as they arrived (usually still compressed) and the compressed images go to a private file on disk. GitHub's sleeping tab takes 2.5 MB, a Wikipedia article 1.2 MB, MDN 57 KB.

Selecting a tab rebuilds it from that file without the network, at its old scroll position, in 5 to 45 ms. And because sleeping tabs share stylesheets, scripts, fonts and images, six tabs (three Wikipedia articles, two GitHub repositories and example.com) take 1.7 MB on disk instead of 2.9 MB.

JavaScript, parsed only when it runs

Broxee's JavaScript interpreter is written in the repository too. Many sites ship far more script than they run on a given page, so the most recent change parses a function's body only the first time it's called. On a site with 868 KB of Next.js script, peak memory from the command line dropped from 40.3 to 27.0 MB, and in a window from 63 to 52 MB.

Where it stands

As of today the binary is 3.7 MB, Wikipedia peaks at 15.7 MB, and Hacker News at 14.0 MB. Four panes side by side, showing GitHub, Wikipedia, Hacker News and example.com, peak at 47 MB.

Most of these tricks aren't new. Production engines bucket CSS rules, filter selectors with bloom filters and share styles between siblings too. What a hard budget changes is that you can't postpone them. Every feature has to fit, so every feature gets measured the day it lands.

The full budget log, with every change and its numbers, is in the Broxee README. If you know a trick we haven't tried, open an issue.

All posts