Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Unused JavaScript over 500 KB: how to find and remove it

PRF-014Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Your browser must download, parse and run every script a page loads. Unused JavaScript is the part of that code which never executes on the page, or does not run until a visitor does something. Lighthouse lists it under the audit called "Reduce unused JavaScript".

Common sources are page builder bundles, sliders, theme scripts, plugins that load on every page, tag manager containers full of old tags, chat widgets and one big app bundle shared by every route.

Why it costs you leads or sales

Every extra kilobyte must travel over the network and then be parsed and compiled. On a mid-range phone that work blocks the main thread, so the page paints later and buttons respond late. Slow landing pages lose visitors before they see your offer, and paid clicks are wasted.

How heavy JavaScript delays a lead
  1. Ad clickVisitor lands on the page
  2. Download scriptsOver 500 KB of unused code fetched
  3. Main thread busyParsing delays the hero and clicks
  4. Form submittedVisitor has already left

Large bundles compete with the hero content and delay everything after them.

LCP before and after trimming scriptsExample numbers
LCP before and after trimming scripts (example)Before (900 KB unused JS): 4.2 seconds; After (250 KB unused JS): 2.6 seconds0234.22.6Before (900 KB unused…After (250 KB unused …seconds

Example: illustrative numbers for a mobile landing page, not measured results.

How to check if your site has it

Find unused JavaScript
  1. Run Lighthouse

    In Chrome, open DevTools (F12), choose the Lighthouse tab, select Mobile and run a report. Open the "Reduce unused JavaScript" audit to see each file and its wasted bytes.

  2. Try PageSpeed Insights

    Paste the URL into pagespeed.web.dev for the same audit plus real-user data where available.

  3. Use the Coverage tab

    In DevTools press Ctrl+Shift+P (Cmd+Shift+P on Mac), type "Show Coverage", click reload and sort by Unused Bytes.

  4. Identify the owner

    Check each large file's path. It usually points to a theme, a plugin, a tag manager container or a third-party domain.

How to fix it

Work from the biggest file down. For each one, decide: remove it, load it only on pages that need it, delay it, or split it.

Fix by platform
  1. Find the plugin behind the file

    The file path in Lighthouse usually contains /wp-content/plugins/name/. Deactivate plugins you do not use.

  2. Load scripts only where needed

    Use a plugin that lets you disable scripts per page (for example Asset CleanUp or Perfmatters), or dequeue them in code. Test the page after each change.

  3. Delay non-essential scripts

    Use your caching or optimisation plugin's defer or delay-until-interaction option for chat, sliders and widgets. Do not delay scripts your form needs.

Load a widget only when it is neededjavascript
const button = document.querySelector('#open-chat');

button.addEventListener('click', async () => {
  const { startChat } = await import('./chat-widget.js');
  startChat();
}, { once: true });
Defer a script that is not needed for first painthtml
<script src="/js/carousel.js" defer></script>

How to confirm it's fixed

After your changes
  • Re-run Lighthouse on mobile and compare the unused JavaScript total with the first run.
  • Check that the largest files in Coverage are gone or much smaller.
  • Reload the page and make sure menus, sliders and pop-ups still work.
  • Submit a test lead and confirm it reaches your inbox or CRM.
  • Check your ad and analytics tags still fire, for example in tag manager Preview mode.
  • Re-test LCP on the real landing page after a few days of field data.

How to prevent it happening again

Keep scripts under control
  • Ask what a new plugin, app or tag adds in kilobytes before installing it.
  • Remove tools when a campaign or trial ends.
  • Review your tag manager container every quarter.
  • Set a script budget for landing pages and run Lighthouse after each release.
  • Load widgets on interaction instead of on page load.

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard runs your real customer journeys on a schedule and checks that steps work, tracking hits are sent and test leads arrive. It does not measure how much JavaScript a page ships or how much of it goes unused.

For this issue, use a page performance tool: Lighthouse, PageSpeed Insights or WebPageTest for lab tests, plus a bundle analyzer such as webpack-bundle-analyzer if you build your own code. FunnelGuard fits alongside them to confirm that your forms and tracking still work after you remove or delay scripts.

Questions people ask

What does unused JavaScript mean in Lighthouse?

It means the page downloaded JavaScript that did not run during load. Lighthouse lists each file with the bytes it could save if the unused part were removed or delayed. It is a hint to investigate, not always an error.

How do I find unused JavaScript on my website?

Run Lighthouse in Chrome DevTools and open the "Reduce unused JavaScript" audit. For more detail, open the Coverage tab (Ctrl+Shift+P, then "Show Coverage"), reload the page and sort by unused bytes.

How much unused JavaScript is too much?

There is no fixed limit, but over 500 KB of unused code is a clear sign of trouble on a landing page. Aim to cut the largest files first, especially those on mobile.

Does unused JavaScript hurt SEO?

It can, indirectly. Extra code slows loading and can worsen Largest Contentful Paint, which is part of Google's page experience signals. It also costs conversions when visitors leave a slow page.

How do I remove unused JavaScript in WordPress?

Deactivate plugins you do not use, then use a script manager plugin such as Asset CleanUp or Perfmatters to stop scripts loading on pages that do not need them. Test your forms and tracking afterwards.

Will deferring JavaScript fix unused JavaScript warnings?

Not fully. Defer stops scripts blocking rendering, but the bytes are still downloaded, so Lighthouse may still report them. To cut the bytes, remove the script or split it so it loads only when needed.

Can tag manager tags cause unused JavaScript?

Yes. Old, duplicate or broadly triggered tags can load large libraries on every page. Remove tags you do not use and limit triggers to the pages where each tag matters.

Does FunnelGuard detect unused JavaScript?

No. FunnelGuard checks that journeys, tracking hits and test leads work, not how much code a page loads. Use Lighthouse, PageSpeed Insights or WebPageTest for this issue.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.