Duplicated JavaScript: find the second copy and remove it
Why Lighthouse finds two copies of React or lodash, why Wix sites show it and WordPress sites hardly ever do, and how to load each library once.
Why does Lighthouse say your JavaScript is duplicated?
Duplicated JavaScript, called Remove duplicate modules in JavaScript bundles before Lighthouse 13, means two of your scripts contain the same package, such as React or lodash, so every visitor downloads and runs it twice. It is unscored. Build the scripts that share a library together, so the library is in one file; on Wix, use fewer Wix apps on a page.
Just want the quick fix? Jump to Wix, WordPress and Shopify or your own build.
How does Lighthouse find duplicated JavaScript?
Lighthouse reads each script's source map, a file next to the minified script that lists the packages in it, and counts a package in the maps of two scripts as a duplicate. The notice reads: "Remove large, duplicate JavaScript modules from bundles to reduce unnecessary bytes consumed by network activity".

A sofa shop's test page in a Lighthouse mobile report, with the simulated throttling PageSpeed Insights uses: React DOM and lodash in both scripts.
Each row under Source is a package (node_modules/react-dom is React DOM) or one source file, by its path. Under it are the scripts that contain it. Lighthouse counts the largest copy as the original and shows two dashes next to it; the Duplicated bytes of the other scripts are the extra bytes your visitors download. Rows are rounded to 10 KiB, so a small package shows 0 KiB and still counts in Est savings. Est savings with an empty table usually means two versions of one package inside one script.
Red means Lighthouse estimates that the extra bytes delay your first paint (FCP) or your largest element (LCP), usually through a script in the head; orange means it only counts the bytes. Unscored: your Performance score stays the same, but your visitors still download every copy.
How much slower is a page with two copies of React?
The part of the page that needs the duplicated scripts appears later: on a shop, the product options and the Add to basket button. The browser downloads, compiles and runs every copy: each file is a separate script.
I built a sofa shop's product page with a React configurator in two ways: the header and the configurator as two separate builds, each with its own React, React DOM and lodash, and as one build that shares a single copy. Both loaded on a phone connection of 1.6 Mbps with 150 ms round trips, with the CPU slowed four times:
| Build | JavaScript (gzip) | Configurator on screen | Scripts running |
|---|---|---|---|
| Two separate builds | 160 kB | 1.91 s | 141 ms |
| One build, one copy | 86 kB | 1.46 s | 58 ms |

Before

After
1.5 seconds into the load: grey blocks where the configurator goes, or the size and fabric choices.
The configurator appeared 0.45 s later. Lighthouse showed the notice orange: it estimated 0 ms of delay for the first paint and the photo. The scripts still download at the same time as the sofa photo and run on the same main thread.
Where does the second copy come from?
View Treemap, a button in the Lighthouse report and in PageSpeed Insights, shows each script as a box with its packages inside, by size. A package in two boxes is a copy.

View Treemap in the same report: the outlined boxes, React DOM and lodash, are in both files.
- Two separate builds: the usual cause. A build puts every package its code imports into its own files, so two scripts built separately, by two teams for example, each contain their own React.
- Two versions of one package: two of your dependencies require lodash version ranges that don't overlap, and npm installs both.
npm ls lodashlists every copy with its version. - The same file twice: two script tags load one file. The browser downloads it once and runs it twice, and the report shows the same file name on both lines.
- Wix: Wix's own files and each Wix app, such as Bookings or Forms, bundle their own copies of the same libraries, and Wix publishes the source maps. Every Wix site I tested showed the notice in orange, from 22 to 138 KiB.
- A plugin, app or vendor widget: listed only when its files have a source map, which is rare. That is why the notice hardly ever shows on WordPress or Shopify.
For your own code, a bundle analyser (webpack-bundle-analyzer, rollup-plugin-visualizer) shows the same boxes straight from the build.
Why does jQuery loaded twice pass this notice?
Lighthouse only compares scripts that have a source map, and most library, theme and plugin files have none. Those are often where the real duplicates are: a theme and a plugin that each load their own jQuery, or two slider plugins that each bundle the same slider library. A passed notice tells you nothing about them.
Find them in DevTools: open the Network panel, filter on JS and reload. Look for the same library name twice, or one file loaded from two addresses (your own server and a CDN) or with two different ?ver= numbers. Then keep one copy.
How do you fix Duplicated JavaScript?
Pick the largest row whose files you build or choose. The domain and path under each package tell you whose script it is: static.parastorage.com is Wix, /wp-content/plugins/ is a plugin, and your own domain is usually your own build.
Wix
The listed files are Wix's own. You control how many Wix apps a page uses, and each one brings its own copies: remove the apps and widgets a page doesn't need. The highest number I measured, 138 KiB, was on a page with four Wix apps. Leave the rest: only Wix can change it.
WordPress and Shopify
- Update first: a new version may share the library with the rest of the page.
- Keep one of two plugins that bring the same library, such as two sliders.
- Load it on fewer pages: on WordPress, unload the plugin's script per page with Asset CleanUp or Perfmatters; on Shopify, turn off the embed of an app you don't use (Online Store, Themes, Customize, App embeds) or ask the vendor to load the widget only on the templates that show it.
- A library loaded twice: ask the developer of the plugin, app or theme that brings the second copy to use the copy already on the page. Don't unload either copy with these tools: WordPress then also drops every script that needs it. A second copy is a sign that many plugins or apps each load their own scripts. Remove those you don't need. After you install a new one, check the Network panel for a second copy.
Combining or minifying JavaScript in Asset CleanUp or LiteSpeed Cache clears the notice, because it removes the line that points to the source map. Both copies still download.
Your own build
Turn two separate builds into one build with two entries, and let the bundler move the packages they share into one chunk. In webpack:
// webpack.config.js
module.exports = {
entry: {
site: './src/site.jsx',
configurator: './src/configurator.jsx'
},
optimization: {
splitChunks: { chunks: 'all' },
runtimeChunk: 'single'
}
};
With runtimeChunk: 'single' the page gets one webpack runtime, so a shared module runs once. The page then loads the runtime and the shared file too; HtmlWebpackPlugin adds those script tags. Vite and Rollup share chunks between the entries of one build by default, and Next.js does this for you.
For two versions, npm ls lodash shows which dependency requires which version, and npm dedupe merges the copies whose version ranges overlap. When they don't, update the dependency that requires the old version, or force one version with overrides in package.json (resolutions in Yarn) and test what uses it: a package forced onto another major version can break.
When two script tags load the same file, remove one. For a package the page doesn't use at all, see Reduce unused JavaScript.
Run Lighthouse again and the notice reads "No duplicated JavaScript found". Hiding the source maps, with hidden-source-map in webpack or 'hidden' in Vite, gives the same result while both copies still download, so also check that the total JavaScript in the Network panel went down.
When is a duplicate too small to fix?
Leave an orange row of a few KiB, a vendor's file you need and can't replace, and Wix's own files once each page has only the apps it needs. Fix a framework or a large library in two of your own bundles (tens of KiB, like React DOM on the sofa page), and fix every red notice: there the extra bytes delay your first paint or your LCP.
A page built from several apps and widgets, each with its own framework, needs a decision on which build gives up its copy and how the others load the shared one. We settle that in a power hour, with your own report and Treemap on screen.

Need a faster site?
I'm Arjen, and I've been fixing slow sites for 17 years. If you're running into issues you can't fix yourself, send me your URL and let's have a chat.
Send me your URL
Why isn't our fix working?
Sometimes the CDN still serves the old HTML, or the fix went into the desktop template and mobile uses another one. Send me your URL and the problem, and I reply with a few times. I check your field data first, then we spend one hour on your site, and within a day you have my notes in writing. €350 excl. VAT.
Send me your URLNo developer to build the fix? I do the work myself, on a copy of your site.