Reduce Unused JavaScript WordPress - Load Less, Delay the Rest (2026)

"Reduce unused JavaScript" is one of the most common PageSpeed Insights warnings on WordPress. It means your pages download JavaScript they don't use, usually from plugins, page builders and third-party services.

What the Warning Means

Lighthouse flags JavaScript files with more than 20 KiB of unused code on the page. Unused code still has to be downloaded, and much of it is parsed and compiled, which costs time on mobile.

On WordPress, unused JavaScript usually comes from:

Find the Unused JavaScript

Illustration for Find the Unused JavaScript on the Reduce Unused JavaScript WordPress page, showing a code diagram
  1. Check PageSpeed Insights

    The unused JavaScript diagnostic lists files and how much of each is unused.

  2. Identify the source

    URLs with /wp-content/plugins/name/ come from that plugin; external domains are third-party services.

  3. Use the Coverage panel

    In Chrome DevTools, the Coverage panel shows how much of each file runs on the page.

  4. Check several page types

    A file unused on the homepage might be essential on product pages.

Three Ways to Reduce It

Options for unused JavaScript
ApproachWhat It DoesBest For
RemoveUninstall the plugin or serviceFeatures you don't need
Unload per pageStop a script loading on pages that don't use itPlugins used on a few pages, like forms or sliders
Delay until interactionLoad the script only after the visitor interactsAnalytics, chat, pixels, social widgets
DeferRun after HTML parsingScripts needed on load but not urgently

Option 1: Remove What You Don't Need

The cleanest fix is deleting plugins and services you don't use. Review your plugin list and your tag manager for:

Option 2: Unload Scripts Where They're Unused

Illustration for Option 2: Unload Scripts Where They're Unused on the Reduce Unused JavaScript WordPress page, showing a code diagram

Many plugins load their JavaScript sitewide. A contact form plugin's script on every page is a classic example.

Test carefully after unloading, since some scripts are needed in places you don't expect, like a form in a footer widget.

Option 3: Delay JavaScript Until Interaction

Delaying doesn't reduce what's downloaded eventually, but it removes the scripts from the initial load, which is what PageSpeed Insights and real visitors care about first. Unused JavaScript warnings often shrink or disappear because the scripts no longer load during the test.

WP Rocket's Delay JavaScript execution handles this across the site with one-click exclusions for scripts that must run early. WP Rocket's documentation notes it can't remove unused code from files, but delaying is how it reduces the impact. See Delay JavaScript exclusions.

Common Sources by Plugin Type

Typical unused JavaScript sources
SourceCommon Fix
Contact form pluginsLoad only on pages with forms
Sliders and galleriesLoad only where used, or replace with static images
Page builder widget librariesEnable the builder's per-widget asset loading
WooCommerce scripts on non-shop pagesUnload cart scripts on blog and info pages where safe
Social sharing and feedsReplace with simple links; delay embeds
Analytics and tag managersConsolidate tags; delay non-essential ones
Chat widgetsDelay until interaction
jQuery and plugins depending on itChoose plugins that don't need jQuery where possible

Using the Coverage Panel Step by Step

Illustration for Using the Coverage Panel Step by Step on the Reduce Unused JavaScript WordPress page, showing a code diagram
  1. Open Chrome DevTools

    Visit the page logged out and open developer tools.

  2. Open Coverage

    Use the command menu to show the Coverage panel.

  3. Start recording and reload

    Coverage records which code runs during the load.

  4. Sort by unused bytes

    The biggest files with the most unused code rise to the top.

  5. Interact with the page

    Click menus and buttons; the unused percentage drops for code those interactions need.

  6. Note the sources

    File paths tell you which plugin, theme or service each file belongs to.

Remember that some code is unused during load but needed later, for example a lightbox that runs only when someone clicks an image. That code is a good candidate for delaying rather than removing.

Unloading vs Delaying: Which to Choose

Choosing between unloading and delaying
SituationBetter Choice
Script isn't needed on this page at allUnload it on this page
Script is needed, but only after interactionDelay it
Script must run immediately for the first screen to workKeep it, defer if possible
Third-party tracking that should fire on every visitKeep, or delay and accept some data loss
You're not sure what a script doesDelay first and test, rather than unloading

Combining both works well: unload scripts from pages that never need them, then delay what's left.

Mistakes to Avoid

Unused JavaScript and Core Web Vitals

Unused JavaScript affects TBT and INP most, because downloaded scripts are parsed and often executed on the main thread. It can also delay LCP when scripts compete for bandwidth with the main image.

See reducing Total Blocking Time and improving INP.

A Worked Example

A blog's PageSpeed report lists unused JavaScript from a slider plugin, a form plugin, a social sharing plugin and two analytics tags. The slider only runs on the homepage, and the form only on the contact page.

The owner configures the form plugin to load only where its block appears, replaces the homepage slider with a static hero image and removes the slider plugin, switches social sharing to simple links and delays both analytics tags until interaction. The unused JavaScript warning disappears from most pages, and TBT drops substantially.

Reduce Unused JavaScript WordPress FAQ

What does "reduce unused JavaScript" mean?

Your page downloads JavaScript files where much of the code isn't used. Lighthouse flags files with more than 20 KiB of unused code.

Can WP Rocket remove unused JavaScript?

It can't remove code from inside files, but Delay JavaScript execution keeps those scripts out of the initial load, which reduces their impact.

Is it safe to unload plugin scripts?

Yes, on pages where the plugin isn't used, but test carefully, because some features appear in places you might not expect.

Does unused JavaScript affect SEO?

Indirectly, through Core Web Vitals like INP and LCP, which Google uses in its ranking systems.