Skip to main content

Confirm

Are you sure?

Lighthouse · Checked on every page

Unused JavaScriptWhat it checks and how to fix it

What it checks

Reads Lighthouse's unused JavaScript audit, which measures how much of each script the page downloads but never runs during load. Under 50 KB of unused code passes, 50 to 150 KB warns, and 150 KB or more fails. It runs on the pages chosen for Lighthouse.

Why it matters

Every kilobyte of JavaScript has to be downloaded, parsed and compiled, even the parts that never run. Shipping large unused bundles, often whole libraries or third-party widgets, slows loading on mobile and delays the moment the page responds to input.

How to fix it

Open Chrome DevTools → Coverage to see which scripts carry the unused bytes, then:

  • Split the bundle per page or route and load the rest on demand with dynamic import().
  • Import only the parts of a library you use, so the bundler can tree-shake the rest.
  • Remove third-party scripts and libraries the page no longer needs.
// load the chart library only when the chart is shown
button.addEventListener("click", async () => {
  const { renderChart } = await import("./chart.js");
  renderChart(data);
});
// import one function instead of the whole library
import debounce from "lodash/debounce";

Monitor this automatically

Full Stack Audit runs this check and 126 others on your site on a schedule, and emails you when one that passed starts failing.

More Lighthouse checks