Performance February 5, 2026 · 5 min read

The 45 KB Analytics Tax — And How to Reduce It to 2 KB

Your analytics script is probably the heaviest third-party resource on your page. We break down what GA4's script actually does, why it's so large, and how to replace it without losing anything meaningful.

What does your analytics script actually do?

Before you can understand why Google Analytics is 45 KB, it helps to understand what that code is doing. GA4's global site tag (gtag.js) needs to:

  • Identify the visitor and their session (via first-party cookie)
  • Capture page metadata: URL, title, referrer
  • Detect the device type, browser, and OS from the user-agent
  • Queue and batch events to Google's ingestion endpoints
  • Support Google Ads conversion tracking and remarketing audiences
  • Handle the consent mode API (accepting/rejecting cookie signals)
  • Support Enhanced Measurement (scroll depth, outbound clicks, video, file downloads)

That's a lot of surface area. Most of it is features the average small-to-medium website never uses — but you load all of it on every page view.

The actual performance cost

The 45 KB figure is the compressed (gzip) size of gtag.js — the script Google tells you to add to your page. On a standard broadband connection, 45 KB feels fast. But performance impact goes beyond raw transfer size:

  • Parse and compile time: the browser has to parse and JIT-compile the JavaScript. Even 45 KB of minified JS takes measurable CPU time on mid-range mobile devices.
  • DNS lookup: the request goes to www.googletagmanager.com — a different domain. That DNS lookup adds latency on the first visit.
  • Blocking potential: if the script is loaded without async or defer (which many tutorials show incorrectly), it blocks HTML parsing entirely.
  • Subsequent requests: after loading, GA4 makes additional requests to www.google-analytics.com to send event data. Each request is a separate network round-trip.

Google's own PageSpeed Insights tool routinely flags GA4 as a Lighthouse performance issue — specifically for "Reduce JavaScript execution time" and "Avoid chaining critical requests." That's Google's own tool flagging Google's own analytics script.

Why most analytics tools are over-engineered

The features that add weight to analytics scripts are mostly there for large enterprise customers with complex attribution needs: advertising integrations, audience segmentation for ad retargeting, cross-domain tracking, data layer integration, tag manager compatibility.

If you're running a SaaS product, a blog, an e-commerce store, or a marketing site, you probably don't need any of that. What you actually want to know is:

  • How many visitors did I get today, this week, this month?
  • Where did they come from?
  • Which pages are most popular?
  • Are people completing my sign-up or checkout flow?
  • Is my site even online right now?

Answering those five questions doesn't require 45 KB of JavaScript. It requires capturing a page view, a referrer URL, and a few custom events. That can be done in roughly 2 KB.

What a 2 KB tracker looks like

Web Analyzer App's tracker (tracker.js) weighs 2 KB minified and gzipped. Here's what it does:

  • On page load: generates or retrieves an in-memory session UUID, reads the current URL, title, and referrer, and sends a single HTTPS POST to our ingestion endpoint
  • On visibility change (tab hidden for > 30 s): sends a heartbeat to record session duration
  • On page unload: sends a beacon with the final duration
  • On SPA navigation: listens for popstate / pushState and fires a synthetic page view
  • On Tracker.track() call: sends a custom event with the provided name and optional JSON payload

That's it. No advertising code. No consent mode API. No feature flags. No cross-domain tracking. Just the data collection your dashboard actually uses.

The Lighthouse score difference

The practical Lighthouse impact depends on your site's baseline. For a typical marketing site, removing GA4 and replacing it with a 2 KB async tracker tends to improve:

  • Total Blocking Time (TBT) — less JavaScript to parse means less main-thread work
  • First Contentful Paint (FCP) — fewer render-blocking resources or competing network requests
  • "Reduce JavaScript execution time" — GA4 commonly contributes 50–150ms to this warning

For sites already passing Core Web Vitals, the change may not move your score noticeably. For borderline sites, removing a 45 KB third-party script is often one of the highest-impact single changes available.

How to make the switch

Replacing GA4 with a lightweight alternative is a two-step process:

  1. Remove your existing GA4 snippet (the gtag.js script and its configuration block) from your page template.
  2. Add the two-line Web Analyzer App snippet to your <head>:
    <script>window.webanalyzer_key = 'YOUR_KEY';</script>
    <script src="https://webanalyzerapp.com/tracker.js" async defer></script>

If you were using GA4 custom events, you can replicate them with Tracker.track('event_name', { your: 'data' }). The event shows up in your dashboard immediately — no tag manager required.

Ready to trim your page weight and get analytics that respect your visitors? Start for free — the tracker installs in under 2 minutes.

All articles Try Web Analyzer App free →