NeovaGeavanceerd SEO-platform

JavaScript-bestand zit boven de Lighthouse-grens voor ongebruikte code

In Neova Draait als Lighthouse aanstaat, een instelling: hij gebruikt de Chrome op je Mac.

Regel laatst nagekeken op 17 oktober 2026 · Gids bijgewerkt op 21 september 2026

Een scriptbestand bevat code die de pagina tijdens het laden niet uitvoerde, dus bezoekers downloaden en parsen die voor niets. Dit is een grens van Lighthouse. Geen enkele zoekmachine legt die vast.

Wat je zou kunnen doen

Splits de bundle zodat code laadt wanneer die nodig is, verwijder dode code, en schrap scripts van derden die de pagina niet gebruikt.

Hoe Neova het vindt

Neova draait een snelheidstest op een steekproef van elk soort pagina.

Waarom Neova dit markeert

  • Bezoekers downloaden en parsen code die de pagina tijdens het laden nooit uitvoert, wat bandbreedte en tijd op de main thread kost.
  • Grote bundels en ongebruikte scripts van derden zijn de gebruikelijke oorzaak.
  • Dit is een grens van Lighthouse; geen enkele zoekmachine legt hem vast.

Bronnen

Het ticket dat hij schrijft

Dit deel is voorlopig in het Engels.

PE-024 · JavaScript File Is Over the Lighthouse Line for Unused Code

How to Check the Fix: 1. Run the check again in Neova
2. Spot-check sample URLs across affected templates
3. Record the re-check date and period label next to the baseline

Neova writes this ticket for every affected page group and sends it to Jira, Linear, Asana and the rest, after you approve it.

De volledige gids

Dit deel is voorlopig in het Engels.

TL;DR, This audit fires when your bundles contain code the page downloads but never executes on load. Dead JavaScript still gets fetched, parsed, and compiled, so it steals network bandwidth and boot-up CPU before a single line of it ever runs, if it runs at all.

What This Check Flags

Lighthouse measures byte-level coverage of every script and reports how much of each file went unused during page load. A 400 KB bundle where only 120 KB executes has 280 KB of pure overhead: bytes the browser fetched, parsed into an AST, and handed to the compiler for nothing. This is a shipping problem, not a runtime one, the fix is to stop sending the code, not to make it run faster.

A Real Example, and the Fix

You import a whole utility library to use one function:

import _ from 'lodash';                 // pulls the entire library into the bundle
const unique = _.uniq(ids);

Even with tree-shaking configured, a default CommonJS import of lodash often drags in the full module because the bundler can't prove the rest is side-effect-free. Import the single function from its own path so only that code lands in the bundle:

import uniq from 'lodash-es/uniq';      // one function, tree-shakeable
const unique = uniq(ids);

For code tied to a screen the user may never open, don't import it statically at all, load it on demand:

button.addEventListener('click', async () => {
  const { openEditor } = await import('./editor.js'); // fetched only on click
  openEditor();
});

The Three Ways Dead Code Gets In

Unused JavaScript almost always traces back to one of these root causes. Naming which one you have points straight at the fix.

Root Cause What It Looks Like The Fix Tool
Whole-library imports import _ from 'lodash' for one helper Import single functions; use ES-module builds Tree-shaking / bundle analyzer
Everything in one bundle Route B's code shipped on Route A Route-based code splitting Dynamic import()
Polyfills for modern browsers Legacy shims served to Chrome/Safari Serve modern JS with module/nomodule Differential serving
Abandoned features Old A/B tests, dead components Delete the source; verify with coverage DevTools Coverage tab

How to Detect It

  1. Lighthouse / PageSpeed Insights: open "Reduce unused JavaScript" under Diagnostics. It lists each script with the wasted bytes and estimated savings, ranked so you fix the biggest offender first.
  2. DevTools Coverage tab: open DevTools, run "Show Coverage" from the command menu, reload, and read the unused percentage per file. Then exercise real interactions, the number should drop as code you actually use finally executes; whatever stays red on a full journey is a deletion candidate.
  3. Bundle analyzer: run webpack-bundle-analyzer or the Vite/Rollup visualizer to see which modules bloat each chunk, so you catch a fat dependency at build time instead of on a live page.

How to Fix It

  1. Turn on tree-shaking properly. Use ES-module imports, mark packages side-effect-free where safe, and build for production so the bundler can drop unreachable exports. Start with the tree shaking primer if the concept is new.
  2. Code-split by route and interaction. Load a view's code only when the user visits it. The code splitting pattern with dynamic import() is the workhorse here.
  3. Import narrowly. Pull single functions from their own paths instead of whole libraries, and prefer smaller dependencies for one-off needs.
  4. Kill dead features. Delete abandoned components and stale experiment code at the source, then re-run Coverage to confirm the bytes are gone.
  5. Defer third parties. Tag managers and widgets are often the biggest chunk of unused JS on load, audit each and load non-essential ones after first paint.

How This Differs From Reduce JavaScript Execution Time

These two are cause and effect, not duplicates. Unused JS is measured in bytes and coverage, how much code you shipped that never ran. Reduce JavaScript execution time is measured in CPU seconds, how long the code that does run takes on the main thread. Deleting unused code helps both audits, because bytes you never send are never parsed or compiled. But you can pass this audit and still fail execution time if the code you do ship runs expensively. Also note the sibling audit Minify JavaScript shrinks the code you keep; removing unused code deletes the code you don't. Do both.

FAQ

Is Unused JavaScript the Same as Unminified JavaScript?

No. Minification compresses the code you keep by stripping whitespace and shortening names. Removing unused code deletes code you never run. They stack: purge the dead code, then minify what survives.

Why Does Tree-Shaking Sometimes Fail to Remove Code?

Tree-shaking relies on static analysis of ES modules. CommonJS imports, dynamic property access, and packages not marked side-effect-free defeat it, so the bundler keeps the code to be safe. Use ES-module builds and a proper sideEffects field to unblock it.

Will Code Splitting Increase the Number of Requests?

Yes, slightly, but over HTTP/2 that trade is almost always a win, because you defer bytes the user may never need instead of blocking the first load with all of them.

How Much Unused JS Is Acceptable?

There is no hard pass line like other audits, but treat anything above roughly 40 KB of wasted script as worth chasing. On mobile, every 100 KB of unnecessary JavaScript is real parse-and-compile time on a slow CPU.

Can I Remove Unused Code From Third-Party Scripts?

Usually not directly, you don't control their bundles. What you can control is whether they load at all and when. Audit each vendor, drop the ones you don't need, and defer the rest past first paint.

Vind dit op je eigen site

Neova voert deze check en alle andere bij elke crawl uit en schrijft de oplossing als ticket voor je team.

  • Desktop-app voor Mac, Windows en Linux
  • Alle 696 checks, elk met zijn bron
  • Search Console en Analytics 4, alleen-lezen gekoppeld
  • Tickets naar Jira, Linear en Asana

Download Neova Desktop Free-abonnement, of Solo 14 dagen gratis, zonder kaart.

Alle checks in de categorie Prestaties · Gidsen · Checkbibliotheek

Geschreven door Neova Labs · Terug naar de Checkbibliotheek