Skip to content
SilktideHelp

Unused JavaScript

Silktide loads your pages in a real browser and measures how much of each script actually runs while the page loads. Scripts with a large amount of unused code are reported, along with the potential saving.

Why this matters

Unused costs your visitors twice: once to download it, and again while the browser parses and compiles code that never runs. On mobile devices, that second cost dominates - a mid-range mobile device can spend several times longer processing a script than downloading it, during which the page can't respond to taps or scrolling.

Unused code accumulates the same way unused CSS does: frameworks and libraries ship features you don't use, and old code rarely gets removed. Every visitor pays for it on every page view.

How to fix it

  1. Remove scripts the page no longer needs, including tags for services you have stopped using.
  2. Split large bundles so each page loads only the code it uses. Modern build tools support code splitting, which does this automatically.
  3. Load code for below-the-fold or on-demand features - modals, players, widgets - only when they are needed, rather than up front:
// Loads the chat widget only when the visitor asks for it
button.addEventListener('click', async () => {
  const { openChat } = await import('./chat.js');
  openChat();
});

How Silktide tests this

  1. Load the page in a real browser and record which parts of each script execute while the page loads.
  2. For each script, measure how many of its bytes never ran.
  3. Report each script with meaningful waste, showing its current size, the percentage unused, and the bytes you could save.

Troubleshooting

The code runs, just not during page load

The measurement covers the initial load. Code that only runs later - form validation, menu handling, features behind clicks - counts as unused even though the page needs it eventually. That code is a good candidate for loading on demand instead of up front.

The unused code is in a third-party script

You usually can't trim someone else's bundle, but you can control when it loads. See 3rd party code and 3rd party facades for approaches.

Learn more

Last updated

Was this page helpful?

Unused JavaScript | Silktide Help