NeovaPlataforma SEO avanzada

Archivo JavaScript por encima del umbral de Lighthouse de código sin usar

En Neova Se ejecuta cuando Lighthouse está activado (un ajuste): usa el Chrome de tu Mac.

Regla revisada por última vez el 17 de octubre de 2026 · Guía actualizada el 21 de septiembre de 2026

Un archivo de script contiene código que la página no ejecutó durante la carga, así que los visitantes lo descargan y lo analizan para nada. Es un umbral de Lighthouse. Ningún buscador lo fija.

Qué puedes hacer

Divide el bundle para que el código se cargue cuando haga falta, elimina el código muerto y quita los scripts de terceros que la página no usa.

Cómo lo detecta Neova

Neova hace una prueba de velocidad en una muestra de cada tipo de página.

Por qué Neova lo señala

  • Los visitantes descargan y analizan código que la página nunca ejecuta durante la carga, lo que cuesta ancho de banda y tiempo del hilo principal.
  • La causa habitual son los bundles grandes y los scripts de terceros que no se usan.
  • Es un límite de Lighthouse; ningún buscador lo fija.

Fuentes

El ticket que redacta

Esta parte está en inglés por ahora.

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.

La guía completa

Esta parte está en inglés por ahora.

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.

Encuéntralo en tu propio sitio

Neova ejecuta esta comprobación y todas las demás en cada rastreo, y luego escribe la corrección como un ticket para tu equipo.

  • App de escritorio para Mac, Windows y Linux
  • Las 696 comprobaciones, cada una con su fuente
  • Search Console y Analytics 4, conectados en solo lectura
  • Tickets para Jira, Linear y Asana

Descargar Neova Plan Desktop Free, o Solo gratis durante 14 días, sin tarjeta.

Todas las comprobaciones de la categoría Rendimiento · Guías · Biblioteca de comprobaciones

Escrito por Neova Labs · Volver a la Biblioteca de comprobaciones