benchmarks6 min read

Web Analytics Script Size Benchmark (1.96 KB)

Measured transfer weights and pricing at scale comparing TrimStats (1.96 KB gzipped, 1.73 KB Brotli) against GA4, Plausible, Fathom, and Umami.

Imtiaz Rayhan
Imtiaz RayhanCo-Founder & Lead Engineer, DotCamp & TrimStats
First-party benchmark: Direct byte measurements of compiled packages/tracker/dist/t.js (raw, gzip level 9, Brotli) paired with verified Nov 2026 vendor specs and pricing tiers.(packages/tracker/scripts/check-size.mjs)
Executive finding

How much faster and smaller are lightweight analytics trackers compared to Google Analytics 4?

TrimStats ships its entire tracker (t.js) at 1,964 bytes gzipped and 1,732 bytes over Brotli (3,508 bytes uncompressed), roughly 20x smaller than base Google Analytics 4 gtag.js (35 to 45 KB gzipped) and 68x smaller than GA4 paired with Google Tag Manager (135+ KB). Using text/plain sendBeacon also eliminates CORS OPTIONS preflight round trips on every event.

Key takeaways
  • Measured directly from packages/tracker/dist/t.js, TrimStats transfers 1,732 bytes via Brotli and 1,964 bytes via gzip level 9 with zero external dependencies.
  • An automated CI script (packages/tracker/scripts/check-size.mjs) fails any pull request that pushes t.js past a 3,072-byte (3 KiB) gzipped hard ceiling.
  • Sending beacons via navigator.sendBeacon with Content-Type: text/plain qualifies as a CORS simple request, eliminating extra OPTIONS preflights on every pageview.
  • Unlike lightweight trackers that strip out funnels, cohorts, revenue webhooks, and UI friction, TrimStats keeps all capabilities inside one sub-2 KB bundle.

Why script bytes still matter in 2026

Every kilobyte of third-party JavaScript added inside <head> is taxed twice: once on the wire over mobile networks, and again on the browser main thread during parse, compile, and execution. On mid-tier Android hardware, decompressing and executing 135 KB of tag manager and analytics libraries directly delays framework hydration and hurts Interaction to Next Paint (INP).

Many engineering teams assume lightweight trackers force a downgrade to bare pageview counters. To test what actually fits inside a strict sub-2 KB transfer budget, we measured our production build of TrimStats t.js alongside verified public specs for Google Analytics 4, Plausible, Fathom, and Umami.

TrimStats transfers 20x smaller than GA4 gtag.js and 68x smaller than GA4 + GTM

Compressed network transfer weight in kilobytes (KB, gzipped)

KB
TrimStats t.js (all-in-one + friction)(1,964 B measured)
1.96 KB1x baseline
Umami script.js(published spec)
~2.0 KB1x baseline
Fathom script.js(gzipped range)
~2.1-2.7 KB1.2x
Google Analytics 4 (base gtag.js)(without GTM)
~35-45 KB20.4x
GA4 + Google Tag Manager + Signals(typical ad stack)
~135 KB68.9x

Base gtag.js alone transfers roughly 20x more compressed JavaScript than TrimStats t.js before a single marketing tag or consent SDK loads.

Methodology: TrimStats measured directly from packages/tracker/dist/t.js using zlib gzip level 9. Third-party figures reflect documented vendor specifications and public network transfer benchmarks.

View chart data table
LabelGzipped script transfer
TrimStats t.js (all-in-one + friction)1.96 KB
Umami script.js~2.0 KB
Fathom script.js~2.1-2.7 KB
Google Analytics 4 (base gtag.js)~35-45 KB
GA4 + Google Tag Manager + Signals~135 KB

Measuring packages/tracker/dist/t.js byte by byte

TrimStats compiles packages/tracker/src/index.ts with esbuild into a single zero-dependency browser IIFE (dist/t.js). Rather than estimating size from marketing copy, every build runs packages/tracker/scripts/check-size.mjs against the real artifact:

# Reproducible measurement against compiled packages/tracker/dist/t.js
wc -c packages/tracker/dist/t.js            # 3,508 bytes raw minified
gzip -9 -c packages/tracker/dist/t.js | wc -c   # 1,964 bytes gzipped (1.96 KB)
brotli -c packages/tracker/dist/t.js | wc -c    # 1,732 bytes Brotli  (1.73 KB)

We enforce a hard CI budget of 3,072 bytes (3 KiB) gzipped so future feature additions can never quietly bloat the tracker into a 20 KB SDK. Today the shipped bundle sits 36% below that ceiling.

Exact TrimStats t.js byte measurements across encodings vs CI hard budget

Compiled artifact packages/tracker/dist/t.js measured in kilobytes (KB)

KB
Brotli transfer (CDN default)(1,732 bytes)
1.73 KB
Gzip level 9 transfer(1,964 bytes)
1.96 KB
CI hard gzip budget(3,072 bytes (3 KiB))
3.07 KB
Uncompressed minified JS(3,508 bytes)
3.51 KB

Keeping uncompressed minified JavaScript under 4 KB ensures fast main-thread parsing even on low-end mobile CPUs.

Methodology: Measured directly on macOS against packages/tracker/dist/t.js using wc -c, gzip -9, brotli, and packages/tracker/scripts/check-size.mjs.

Source: TrimStats repository build artifact (packages/tracker/dist/t.js)
View chart data table
LabelArtifact size
Brotli transfer (CDN default)1.73 KB
Gzip level 9 transfer1.96 KB
CI hard gzip budget3.07 KB
Uncompressed minified JS3.51 KB

What actually fits inside 1,964 bytes gzipped

Keeping an analytics script under 2 KB requires disciplined engineering rather than stripping out useful SaaS telemetry. Inside 1,964 B gzipped, t.js handles eight distinct jobs with zero runtime dependencies:

  1. Automatic pageviews & SPA routing: Wraps history.pushState and listens to popstate for Next.js App Router, React Router, Vue, and Astro View Transitions.
  2. Visibility-aware active engagement: Pauses dwell timing whenever document.visibilityState === 'hidden' so background tabs never inflate visit time or distort the 10-second bounce rule.
  3. Outbound link & file download capture: Detects external origins and common downloadable asset extensions automatically via delegated listeners.
  4. Dual-mode identity: Writes zero storage in default cookie-less mode and persists _ts_vid + _ts_attr in localStorage only when data-mode="first-party" is opted in.
  5. Pre-load FIFO command queue: Replays queued window.trimstats.q calls for event and identify before dispatching the initial pageview.
  6. Checkout attribution snapshot: Exposes window.trimstats.attribution() so Stripe, Paddle, and Polar checkouts attach clean acquisition metadata.
  7. Opt-in UI friction diagnostics: Attaches rage-click, dead-click, and 90% scroll detectors only when data-friction="true" is present.
  8. Zero-preflight beacon delivery: Submits JSON payloads via navigator.sendBeacon with new Blob([body], { type: 'text/plain' }), avoiding cross-origin OPTIONS preflight round trips on every hit.
Seeded demo workspace
TrimStats Overview dashboard powered by the 1.96 KB t.js script showing real-time visitors, active engagement time, and click-to-filter breakdownsTrimStats Overview dashboard powered by the 1.96 KB t.js script showing real-time visitors, active engagement time, and click-to-filter breakdowns
A sub-2 KB tracker does not require sacrificing product depth: live visitors, active dwell time, funnels, revenue webhooks, and UI friction all flow from one deferred tag.

Lightweight scripts vs pricing at SaaS scale

Performance is only half of the evaluation for growing SaaS products. Many lightweight analytics vendors charge steep feature gates once you need multi-step funnels, revenue attribution, or 1M to 5M monthly events.

When comparing verified November 2026 cloud pricing across full-featured tiers:

  • Plausible Analytics ships a sub-1 KB base script for pure traffic, but requires its Business tier ($39/mo at 100k, $139/mo at 1M, $259/mo at 5M) to unlock funnels and revenue tracking.
  • Fathom Analytics scales cleanly on sites and forever retention ($15/mo at 100k, $60/mo at 1M, $140/mo at 5M), but omits funnels, cohorts, signed revenue webhooks, and UI friction.
  • Umami Cloud is aggressive at 1M events ($20/mo Pro), then meters $0.00003 per extra event ($140/mo at 5M) and gates replays/heatmaps behind $200/mo Business.
  • TrimStats includes every feature across all tiers: $17 (100k), $44 (1M), and $134 (5M events/month) with a 20% soft grace buffer and bot traffic dropped pre-billing.

Monthly cloud cost across lightweight privacy analytics at 100k, 1M, and 5M events

Verified monthly USD pricing for full-featured plans (Nov 2026)

USD/mo
TrimStats (All features)
Fathom Analytics
Umami Pro (+ overages)
Plausible Business
Monthly cloud cost across lightweight privacy analytics at 100k, 1M, and 5M eventsAt 5M monthly events, TrimStats Scale ($134/mo) saves $6/mo vs Fathom and Umami Pro overages and $125/mo vs Plausible Business.065130194259$17/mo$15/mo$20/mo$39/mo100k events$44/mo$60/mo$20/mo$139/mo1M events$134/mo$140/mo$140/mo$259/mo5M events

At 5M monthly events, TrimStats Scale ($134/mo) saves $6/mo vs Fathom and Umami Pro overages and $125/mo vs Plausible Business.

Methodology: Monthly USD billing verified on 2026-11-30 from official vendor pricing pages. Plausible Business shown for funnel/revenue parity; Umami 5M includes $20 base + 4M x $0.00003 overage.

Source: Official vendor pricing pages (Nov 2026)
View chart data table
LabelTrimStats (All features)Fathom AnalyticsUmami Pro (+ overages)Plausible Business
100k events$17/mo$15/mo$20/mo$39/mo
1M events$44/mo$60/mo$20/mo$139/mo
5M events$134/mo$140/mo$140/mo$259/mo

Reproducing the check on your own site

Open Chrome DevTools on any production site, switch to the Network tab with Disable cache enabled, filter by JS, and compare the total Transferred and Resource bytes of your current analytics and tag manager scripts against 1.96 KB gzipped.

Pay attention to three numbers rather than just the first script request:

  1. Chained requests: Tag managers often download an initial 35 KB loader that dynamically injects two or three extra 25 to 60 KB scripts during hydration. Sum every third-party analytics and tag request triggered before load settles.
  2. Main-thread scripting duration: Open the DevTools Performance panel with 4x CPU throttling enabled and look for long tasks attributed to analytics scripts during page load and first user click. A 3,508-byte zero-dependency script parses in sub-millisecond time, whereas 135 KB bundles regularly consume 30 to 90 ms of mobile main-thread time right when users try to click hero buttons.
  3. Beacon network overhead: Filter the Network panel by collect or g/collect and verify whether each pageview fires a single POST request or triggers a paired OPTIONS preflight first. Eliminating preflights saves an entire TCP/TLS round trip on every route change over mobile networks.

Enforcing script size as a permanent CI invariant

Performance budgets fail whenever they rely on periodic manual audits. In TrimStats, packages/tracker/scripts/check-size.mjs runs automatically after esbuild bundles t.js, compressing the output at gzip level 9 and exiting non-zero if size ever crosses 3,072 bytes. Treating tracker bytes like a failing unit test guarantees Core Web Vitals stay protected as new analytics capabilities ship on the server side in ClickHouse instead of inside visitor browsers.

If you want to see how we also fit privacy-safe rage-click and dead-click detection inside the exact same 1,964 B bundle without session-replay overhead, read How TrimStats Detects UI Friction Without Session Replay.

Frequently asked questions

Why does analytics script size affect Core Web Vitals if the script has defer?
Even a deferred script still consumes network bandwidth, main-thread JavaScript parse and compile time, and CPU cycles during hydration. When analytics tags exceed 40 to 135 KB or spawn chained Tag Manager containers, they compete with React hydration and increase Total Blocking Time (TBT) and Interaction to Next Paint (INP) on mobile devices.
How does TrimStats avoid CORS OPTIONS preflight requests on every pageview?
Browsers send a CORS preflight OPTIONS request before cross-origin POST requests with Content-Type: application/json. TrimStats sends JSON payloads via navigator.sendBeacon with a text/plain Blob, which qualifies as a CORS simple request and cuts beacon network round trips in half.
Does Plausible have a smaller base script than TrimStats?
Yes. Plausible base traffic script is under 1 KB gzipped for pageviews only, whereas TrimStats ships a single 1.96 KB gzipped (1.73 KB Brotli) bundle that already includes SPA pushState tracking, outbound links, file downloads, attribution snapshots, and opt-in UI friction without loading extra script extensions.
How can I verify the actual transferred size of any analytics script on my site?
Open Chrome DevTools Network tab, disable browser cache, reload your page, and inspect the Size column (compressed transfer bytes) versus the Resource Size column (uncompressed bytes) for your analytics host. Check also whether extra sub-scripts or OPTIONS preflight requests fire on each pageview.
Does TrimStats enforce its sub-2 KB tracker weight automatically in CI?
Yes. The repository runs packages/tracker/scripts/check-size.mjs on every build to measure packages/tracker/dist/t.js and fail CI if the gzipped bundle ever exceeds its hard 3,072-byte (3 KiB) ceiling. The live shipped tracker measures 1,964 bytes gzipped and 1,732 bytes over Brotli.
Does enabling opt-in UI friction or revenue attribution increase TrimStats script bytes?
No. Opt-in rage click, dead click, and 90% scroll reach listeners plus window.trimstats.attribution() are already compiled inside the single 1.96 KB gzipped t.js bundle, and revenue webhooks run entirely server-side with zero additional browser JavaScript.

Sources & references

Imtiaz Rayhan
Written & verified by
Imtiaz Rayhan (Co-Founder & Lead Engineer, DotCamp & TrimStats)

Co-founder of DotCamp LLC in Brooklyn, NY and lead engineer of TrimStats. Ships privacy-first web analytics, ClickHouse pipelines, and WordPress plugins used on 115,000+ active sites.

  • • Architect of the TrimStats 1.96 KB gzipped browser tracker, Fastify collector, and ClickHouse MergeTree pipeline
  • • Co-founder of DotCamp LLC (est. 2019), creator of Ultimate Blocks (50,000+ installs), WP Table Builder (50,000+ installs), Tableberg, and OptimizeCamp
  • • WordPress.org plugin & theme developer since 2016 with 1,200+ community support replies and 5M+ cumulative plugin downloads

Verification standard: First-party benchmark: Direct byte measurements of compiled packages/tracker/dist/t.js (raw, gzip level 9, Brotli) paired with verified Nov 2026 vendor specs and pricing tiers.

Measure traffic, revenue, and UI friction in 1.96 KB gzipped

Cookie-less by default, powered by ClickHouse, and starting at $17/month for 100,000 monthly events with every feature unlocked.