Engine

Why a Lightweight Browser Blocks Ads at the Network Layer

Nemo · · 4 min read

The cheapest request a browser can make is the one it never makes. Blocking ads and trackers at the network layer means the browser checks every outgoing request against filter lists and drops the ones that match, before a single byte is downloaded or a line of script runs. For a browser built to be light, that is not a privacy extra: it is part of the performance budget. Monok has it built in, on by default, in version 0.1.0.

What does “at the network layer” mean?

There are two places a browser can fight ads:

Where What happens What it saves
Network layer The request to an ad or tracking server is cancelled before it is sent Download, parsing, script execution, memory, and the data the tracker would have collected
Page layer (cosmetic) The page loads, then CSS rules hide leftover ad boxes A cleaner page; no network or memory savings for what was already loaded

Network blocking does the heavy lifting. Cosmetic hiding cleans up the empty frames and “advertisement” labels that remain when the ad itself never arrived.

Why does it make pages lighter?

Ad and tracking code is usually JavaScript, and a JavaScript engine keeps what it runs in memory: parsed code, objects, timers, often more network requests of its own. A third-party script that never loads costs nothing. The savings show up in:

  • Load time. Fewer connections to open, fewer bytes to fetch, less script to run before the page settles.
  • Memory. No heaps for scripts that never ran.
  • Privacy. A request that is never sent can’t carry a cookie or a fingerprint.

We haven’t published before and after numbers for blocking yet. When we do, they will come with the pages and the method, instead of quoting someone else’s.

How does blocking work in Monok?

  1. The lists: EasyList (ads) and EasyPrivacy (trackers), community-maintained filter lists, bundled with the app and updated every week from easylist.to. Settings has an “Update now” button.
  2. The conversion: Brave’s open-source adblock-rust library turns the lists into WebKit content rule lists: about 128,000 rules, most of them request blocks and about 24,000 element-hiding rules.
  3. The engine: WebKit, which renders pages in Monok v1 (here is why), applies those rules to every request and hides matching elements. The rules are compiled once per list version and reused, so a normal launch doesn’t pay for them.
  4. Your control: the ⋮ menu shows how many requests were blocked on the page and turns blocking off for that site. Settings turns it off everywhere and lists the sites where it is off.

Because it is part of the browser and not an extension (v1 has no extensions), there is no extra script injected into every page. Pages don’t load unblocked while the rules get ready: the first loads wait for them.

What doesn’t it block?

Content rule lists can’t express everything in the filter lists. Rules that need to rewrite requests or run scripts in the page are dropped, and so are a few complex element-hiding selectors. You can’t add your own list URLs in v1.

Does blocking ever break sites?

Sometimes. A filter can be too broad, or a site can refuse to work when its trackers fail. That is why turning it off for a site is one click in the ⋮ menu, and why the lists are updated weekly as their maintainers fix false positives.

How does this fit the rest of the browser?

Blocking is one piece of a browser that tries to do less: a quiet interface with no address bar and a small app on top of the system’s engine. The architecture post shows where the blocking crate sits. If you want lighter browsing in any browser, the guide to using less RAM has tips.

FAQ

Is ad blocking in the current release?

Yes. Version 0.1.0 blocks ads and trackers by default. Get it on the download page.

Which filter lists does it use?

EasyList and EasyPrivacy, bundled and updated weekly.

Can I turn it off for one site?

Yes. Open the ⋮ menu on that site and turn blocking off; the page reloads without it.

More in Engine

Contact

Bug reports, sites you want to see working, ideas. We reply by email.