Skip to content

How to Load Google Analytics Without Slowing Down Your Website

Every website needs tracking. Google Analytics to understand your users. Facebook Pixel for ads. Hotjar to see how people interact with your site.

But here’s the problem: every script you add makes your website slower.

When you add Google Analytics the normal way:

<script src="https://www.googletagmanager.com/gtag/js?id=G-XXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXX');
</script>

Your browser has to stop everything it’s doing. It connects to Google’s servers, downloads the script, and processes it. During this time, your website can’t respond to users.

Click a button? Nothing happens. Try to scroll? It stutters.

This is called blocking the main thread.

Think of your browser as having one worker who does everything: painting the page, responding to clicks, running animations, loading scripts.

When you add a third-party script, that worker has to stop serving your users and go fetch something from another server. Users wait.

Now imagine you could hire a second worker who handles all the fetching in a back room, while the first worker stays focused on your users.

That’s exactly what Boostify does.

Instead of loading scripts the normal way, you change one small thing. Your script goes from this:

<script src="https://www.googletagmanager.com/gtag/js?id=G-XXXXX"></script>

To this:

<script type="text/boostify" src="https://www.googletagmanager.com/gtag/js?id=G-XXXXX"></script>

The only difference is type="text/boostify".

This tells Boostify: “Don’t load this script normally. Put it in the background.”

When you use type="text/boostify", Boostify:

  1. Waits until your page is ready and the user starts interacting
  2. Sends a helper (called a Web Worker) to fetch the script
  3. Routes the request through our proxy server (because browsers have security rules about loading scripts from other domains)
  4. Injects the script only after your page is fully interactive

Your main thread never stops. Your users never wait. The scripts still load and work perfectly—they just don’t block anything.

Here’s how to set up Google Analytics without slowing down your site:

<!DOCTYPE html>
<html>
<head>
<title>My Fast Website</title>
</head>
<body>
<h1>Welcome</h1>
<!-- Your analytics scripts with type="text/boostify" -->
<script type="text/boostify" src="https://www.googletagmanager.com/gtag/js?id=G-XXXXX"></script>
<script type="text/boostify">
window.dataLayer = window.dataLayer || [];
window.gtag = function(){dataLayer.push(arguments);}
window.gtag('js', new Date());
window.gtag('config', 'G-XXXXX');
</script>
<!-- Boostify at the end -->
<script src="https://unpkg.com/boostify@latest/dist/Boostify.umd.js"></script>
<script>
const bstf = new Boostify({ debug: true });
bstf.onload({ worker: true });
</script>
</body>
</html>

You can use type="text/boostify" with:

  • Google Analytics
  • Google Tag Manager
  • Facebook Pixel
  • Microsoft Clarity
  • Hotjar
  • LinkedIn Insight Tag
  • TikTok Pixel
  • HubSpot
  • Any script from jsDelivr, unpkg, or cdnjs
Without BoostifyWith Boostify
Page loads, then freezes while scripts downloadPage loads and stays responsive
Buttons feel delayedButtons respond instantly
Scroll stuttersScroll is smooth
Users leave frustratedUsers stay and convert

Browsers have security rules that prevent loading scripts from other websites in the background. It’s a protection mechanism.

Boostify’s proxy acts as a trusted middleman. Your site asks our proxy, our proxy gets the script from Google (or Facebook, or wherever), and delivers it back. The browser trusts this because it comes from a single, known source.

The proxy is free, fast, and handles millions of requests.

Our Recommendation: Use Google Tag Manager

Section titled “Our Recommendation: Use Google Tag Manager”

Instead of adding type="text/boostify" to multiple scripts, we recommend using Google Tag Manager (GTM) as your single container.

Why? Because you only need to load one script through Boostify:

<script type="text/boostify" src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXX"></script>

Then add all your other tags (Facebook Pixel, Hotjar, HubSpot, etc.) inside GTM’s interface.

Benefits:

  • One proxy request instead of many
  • Easier to manage (no code changes to add/remove tags)
  • Everything works normally (cookies, tracking, pixels)

GTM loads late through Boostify, which means all the tags inside GTM also start late. Your page is already interactive before any tracking begins.

  1. Add type="text/boostify" to your GTM script (or individual scripts if you prefer)
  2. Include Boostify at the end of your page
  3. Call bstf.onload({ worker: true })

That’s it. Your analytics work exactly the same, but your site stays fast.