How to Fix JavaScript Page Load Time
A practical guide to finding, deferring, splitting, and trimming the scripts that hurt your page load time.

On this page
JavaScript is usually the single biggest driver of slow page load time. Every kilobyte has to be downloaded, parsed, compiled, and executed on the main thread, which is why long tasks on the main thread are such a common cause of slow interactivity. A site with a moderate JavaScript bundle can feel slower than a site with ten times as many images.
The fix is the same whether you build pages in Webflow or Framer or you ship your own bundle from a build pipeline. Send less JavaScript, send it later, and only send what is actually needed. On a no code platform that usually means cutting third party embeds and integrations. On a custom build it usually means smarter bundling. These five steps cover both. For the matching work on other asset types, see slow images and render blocking CSS.
Step 1: Identify the scripts driving page load time
Open DevTools, go to the Network tab, filter by JS, and sort by transfer size. Make two columns on a notepad, first party scripts from your own domain (which on a no code site includes the runtime your builder ships) and third party scripts from analytics, ads, chat widgets, and marketing tools.
Our Website Optimizer does the same breakdown automatically and flags any script heavy enough to measurably delay interactivity. Pay attention to the third party column, since that is often where the easiest wins live.
Step 2: Defer or async third party tags
Most marketing and analytics scripts have no business running during the initial parse. Defer them so the browser can finish building the DOM first.
<script src="https://analytics.example.com/tag.js" defer></script>
<script src="https://chat.example.com/widget.js" async></script>
Use defer for anything that must run in order or that depends on the DOM. Use async for independent fire and forget scripts. If a tag does not need to be present for the page to work, check whether you can load it on user interaction instead, for example after the first scroll or click.
For tag manager setups, audit the triggers. A surprising number of tags fire on every page load when they were only meant to fire on specific events.
If you paste embeds into a custom code field in Webflow, Framer, or a similar builder, the same attributes work. Add defer or async directly to the script tag before pasting it in.
Step 3: Audit and remove unused scripts
If your site is built in Webflow, Framer, or a similar platform, the biggest source of script weight is usually the integrations you have wired up over time. Walk through your installed apps, embeds, and marketing tags and ask whether each one is still earning its place. A chat widget that gets one message a month or an analytics tool nobody on the team checks is pure cost. Where a feature can be built natively in your design tool, prefer that over importing a third party widget for it.
For custom builds, the Coverage panel in DevTools is the fastest way to spot dead weight. Reload the page, interact with it, and then stop recording. Coverage shows each script with the share of bytes actually executed. Anything with a tiny used share is a candidate for removal or scoping.
Common offenders include, legacy polyfills for browsers you no longer support, A/B testing frameworks running on pages with no active tests, and feature flag libraries loading their full SDK instead of a small client.
For your own code, look for dead routes and components that never render in production. A build time tree shake removes unused exports, but only if your imports are structured for it.
Step 4: Split and lazy load your own bundles
If you are on a no code platform, the equivalent of code splitting is keeping heavy embeds off pages that do not need them. Add the chat widget to the contact page, not the site wide footer. Put the booking calendar embed on the booking page only. Most builders let you scope custom code to a single page rather than the whole site, and using that setting properly is the single biggest win available to you here.
For custom builds, shipping a single enormous bundle means every visitor downloads code for every feature, even ones they will never touch. Code splitting breaks that bundle into chunks that load on demand, which is one of the most effective ways to cut page load time on a JavaScript heavy site.
Route level splitting is the easiest place to start. Most modern frameworks do this automatically, but confirm it is turned on.
For heavy components inside a page, use dynamic imports:
const Chart = await import('./chart.js');
Chart.render(data);
This works well for anything the user only sees after an action, including modals, editors, video players, charts, and maps. Run webpack-bundle-analyzer, a Webpack plugin that visualizes the contents of each chunk, to see exactly what you are shipping and make decisions based on real numbers.
Step 5: Minify and compress what remains
By this point you are shipping less JavaScript and loading it later. The last lever is shrinking what is left on the wire, and it is the easiest of the five steps because the tooling does the work for you.
If you are on Webflow, Framer, or another managed platform, both minification and compression happen automatically. You can skip this step and put your time back into the first four. The rest of this section is for teams that ship their own builds.
Start with a minification tool like Terser. It rewrites your code with shorter variable names, strips comments, and collapses whitespace, all without changing how the code runs. Every modern bundler runs Terser by default in production mode, so the only thing to confirm is that your deploy is actually using a production build.
At the server, enable Brotli if available and gzip as a fallback. Most CDNs do this for you, but self hosted setups often ship uncompressed assets without realizing it. Check the Content-Encoding header on your script responses to confirm.
Once these five steps are in place, run your site through our Website Optimizer again. First party bundle size should be down, third party scripts should no longer block the initial render, and both Time to Interactive and overall page load time should move in the right direction.