Skip to content
SilktideHelp

Duplicate JavaScript

Silktide checks whether any of the code your page downloads is included more than once. Duplicate code makes a page larger and slower to load without adding anything for the visitor.

Modern is usually assembled from many small modules that are bundled together into a few large files. When several bundles are built independently - for example your own code plus an embedded widget - each can ship its own copy of the same module, and visitors end up downloading identical functionality twice.

Why this matters

Every duplicated module costs download time, processing time, and mobile data, and delivers nothing in return. On a fast office connection the waste may be invisible, but visitors on phones and slower networks feel it directly as a page that takes longer to appear and respond.

Duplication also tends to grow quietly: each new script or widget added to a site can bring its own copies of common libraries, so the waste compounds over time unless someone looks for it.

How to fix it

This is a fix for your developers, in the site's build process rather than its content:

  1. Analyze how the site's JavaScript is bundled. Most bundling tools have an analysis mode that visualizes what each output file contains, which makes duplicated modules easy to spot.
  2. Configure the build to deduplicate shared dependencies, so a library used in several places is included once and shared, rather than copied into every bundle.
  3. Align versions: two different versions of the same library cannot be merged, so upgrading everything to one version is often the real fix.
  4. If the duplication comes from a third-party script you cannot rebuild, ask the provider for a slimmer build, or replace it.

How Silktide tests this

  1. Load the page in a real browser, using the device type, connection speed, and test location configured for your speed tests.
  2. Examine the JavaScript files the page downloads and identify modules that appear in more than one file. Copies are matched by what they do, so they are found even when the files are formatted or differently.
  3. Report each duplicated module, the files it appears in, and the download size that could be saved by removing the extra copies.
  4. Grade the page by the total wasted download size: even about 10 KB of duplication is graded down, and 50 KB or more is graded as poor.

Troubleshooting

The two files don't contain identical code

The check matches modules by what they are, not by their exact text. The same module can look very different in two bundles after minification, yet still be the same duplicated code.

The duplication is inside a third-party script

You cannot rebuild someone else's bundle. Raise it with the provider, load their script another way that shares your dependencies, or accept the cost if the script's value outweighs it.

Learn more

Last updated

Was this page helpful?