Launch in Days, Not Weeks
Professional one-page website. Only a few slots left this month
Your B2B marketing site might be shipping well over a megabyte of JavaScript. Much of it is analytics, chat widgets, and A/B testing tools that block the main thread for hundreds of milliseconds before the page even feels usable. Your developers probably didn’t write slow code — your marketing stack made it slow. Here’s how to fix it without losing the functionality those tools provide.
You can’t fix what you haven’t measured. Before changing anything, find out what’s actually running.
Chrome DevTools Coverage tab shows you, for any loaded page, how much of your JavaScript is actually executed versus downloaded and never used. It’s common to find that a large share of a bundle never runs on a given page, which is a clear signal for code splitting or removal.
Bundle analysis (via your build tool’s bundle visualiser) shows you what’s actually inside your JavaScript output, broken down by library. This is often where teams discover a single unused dependency accounting for a disproportionate share of total bundle size.
Third-party impact specifically deserves its own audit, separate from your own code. Chrome DevTools’ Performance panel attributes main-thread time to specific scripts, which usually reveals that chat widgets, tag managers, and heatmap tools account for more blocking time than the site’s own functionality.
Start here, not with assumptions. The biggest win is often not in your own codebase at all.
Marketing and analytics tools are usually the biggest, and most fixable, source of JavaScript bloat on a B2B site.
Loading strategies matter enormously. defer and async attributes let scripts download without blocking HTML parsing, but not all third-party snippets support them out of the box. Where possible, load non-critical scripts after the main content has rendered, not in the initial critical path.
Tag managers add their own overhead. Google Tag Manager and similar tools are convenient for marketing teams but introduce an extra layer of script loading and execution on top of whatever tags they’re managing. Audit what’s actually firing through your tag manager; it’s common to find tags nobody remembers adding, still loading on every page.
Conditional loading means only loading a script when it’s actually needed. A chat widget doesn’t need to load on every page if it’s only used on a handful; loading it on interaction (a click to open chat) rather than on page load removes it from the critical path entirely.
Web worker isolation, via tools like Partytown or Cloudflare’s Zaraz, runs third-party scripts off the main thread entirely, in a separate execution context. This is one of the more effective fixes available for sites that can’t simply remove the scripts marketing depends on, because it keeps the tools functioning without them competing for main-thread time.
Beyond third-party scripts, your own application code often carries more weight than necessary.
Code splitting breaks your JavaScript into smaller chunks loaded only when needed, rather than one large bundle downloaded on every page regardless of what that page actually uses.
Tree shaking removes unused code from your final bundle at build time, but only works reliably when dependencies are written in a way that supports it (ES modules, not older CommonJS patterns). Auditing whether your build tool is actually tree-shaking effectively is worth doing directly rather than assuming it’s happening.
Dynamic imports let you load a piece of functionality only when a user actually triggers it — a heavy date picker library, for instance, loaded only when someone opens that specific form field, rather than bundled into the initial page load for every visitor.
The overall principle: a marketing page doesn’t need your entire application’s JavaScript. It needs the JavaScript for what’s actually on that page.
Bundle size and execution time are related but distinct problems. A small bundle that runs an expensive synchronous task can still block interactivity.
Main thread blocking happens when JavaScript execution prevents the browser from responding to anything else, including user clicks and scrolling. This is measured directly by INP, the Core Web Vitals metric that captures how responsive your page actually feels.
Long tasks, any JavaScript execution over 50ms, are the specific unit to hunt for. Breaking a long task into smaller pieces, using scheduler.yield() or similar techniques to let the browser breathe between chunks, keeps the page responsive even while background work continues.
INP impact compounds when a page has both heavy execution and frequent user interaction, which describes most B2B pages with forms, filters, or dashboards. Reducing both bundle size and long task duration together is what actually moves the metric, not just one or the other.
Fixing JavaScript performance once is easy. Keeping it fixed as marketing adds new tools over time is the actual challenge.
Performance budgets set explicit limits on total JavaScript weight (or specific metrics like INP) that new deploys shouldn’t exceed. Without a budget, bundle size creeps upward one “quick add” at a time until the site is slow again within a year.
CI checks can enforce these budgets automatically, failing a build or flagging a warning if a change pushes bundle size or bundle count past agreed thresholds, catching regressions before they reach production rather than after a customer complains.
Real user monitoring tracks actual field performance across your real visitor base, not just lab conditions, so you can see whether your fixes are showing up in genuine user experience, not just a synthetic test.
A slow, JavaScript-heavy marketing site isn’t just a technical embarrassment. It directly affects Core Web Vitals scores, which factor into rankings, and it affects conversion: visitors on slower connections or older devices experience the lag directly, at exactly the moment you’re trying to earn their trust.
This is a core part of what we manage in every managed-systems engagement: not just building a fast site initially, but keeping it fast as new tools and tags get added over time.
Want a JavaScript performance audit of your current site? Book a call and we’ll show you exactly what’s slowing you down and what it will take to fix it.