A 1.1 KB beacon: what we cut, and what we refused to cut

Our browser RUM script ships in 1,082 bytes gzipped. Shrinking it was less about clever minification and more about deciding, feature by feature, what a performance beacon is actually for.

A real-user monitoring script has a credibility problem: it exists to measure how fast your page is, while making your page slower. Every byte it adds, every main-thread millisecond it steals, is working against its own purpose. So we set a hard budget — under 2 KB gzipped, zero layout cost, nothing on the critical path — and treated every feature as something that had to buy its way back in.

Here is what the budget forced.

What we cut

Cookies and identifiers. This was the easy one, because we never wanted them. No cookie, no localStorage, no fingerprint, no visitor ID. Beyond the privacy argument (which we care about — see the privacy page), identity is expensive: it needs storage access, consent logic, and a sync with the server. Dropping it removed whole branches of code.

A config endpoint. The first prototype fetched its configuration at runtime. That is a network round-trip before the script can do anything, and a point of failure if the config host is slow. We moved everything into data- attributes on the script tag. Configuration is now free and synchronous.

Custom transport logic. We had hand-rolled retry and batching. We deleted it and used navigator.sendBeacon, which is built for exactly this: fire-and-forget, survives page unload, does not block navigation. One call replaced forty lines.

Polyfills. We target evergreen browsers for the full feature set and degrade silently on old ones. A browser without PerformanceObserver simply sends the navigation timing it does have. No polyfill ships to the 98% that do not need it.

What we refused to cut

Respecting DNT and GPC. It would have saved a few bytes to ignore Do Not Track and Global Privacy Control. We check both and send nothing when either is set. A performance tool that overrides the user’s stated preference is not a tool we want to ship.

if (navigator.doNotTrack === "1" ||
    navigator.globalPrivacyControl) return;

Core Web Vitals done properly. LCP, INP and CLS are genuinely fiddly: LCP can change until the page is interacted with, CLS accumulates, INP needs the full interaction lifecycle. We could have sent a naive snapshot and called it LCP. Instead we observe the real entries and send on the visibilitychange to hidden, which is the one moment you reliably get on mobile. This cost us maybe 300 bytes. It is the difference between data and decoration.

One beacon, at the right time. We send exactly one beacon per page view, at page hide, with everything batched into it. Not one per metric, not one on a timer. Fewer requests, no duplicate accounting, and it lines up with how the browser actually ends a page’s life.

The number

$ gzip -9c mi.js | wc -c
1082

The honest footnote: 1,082 bytes is the script. The beacon it sends is a few hundred bytes more, once, on a connection the browser was going to tear down anyway. We think that is a fair price for knowing what your users actually experience — and a much fairer one than the 40 KB analytics bundles it replaces.

The discipline that got us here was not minification. It was asking, for every feature, “does a performance beacon need this to do its job?” Most of the time, the answer was no.