Dead Dependencies & Bundle Weight
As projects grow, dependencies accumulate. Tools like `depcheck` identify packages you installed but no longer use, while tools like Bundlephobia help you measure the real-world cost of a package before installing it.
What is it?
Dependency-analysis tools compare declared packages with detected source, script and configuration uses. Reports are candidates for investigation, because tooling and dynamic references can produce false positives. Depcheck is no longer actively maintained.
A package's minified/gzipped estimate is useful for comparison, but it is not the exact cost in your application. Imports, shared dependencies, bundler configuration and tree shaking affect the production output.
Why use it?
Dead dependencies bloat your node_modules folder, increase CI build times, and expand your attack surface for security vulnerabilities, all for code you aren't even using.
Installing massive libraries (like the original moment.js) can add hundreds of kilobytes to your frontend bundle, destroying your app's load time and Web Vitals.
How it works
Review a dependency-analysis report against actual source, scripts, configuration and dynamic references before removing anything. Check tool maintenance and framework support; do not treat a reported unused package as an automatic deletion instruction.
Before installing a new package, go to bundlephobia.com or use npx bundle-phobia-cli <pkg> to check its minified + gzipped size.
Interactive Demo
Explore the concept in action using the interactive visualization below.
{
"name": "my-project",
"dependencies": {
"react": "^18.3.1",
"lodash": "^4.17.21"
}
}* lodash
depcheck scans your src/ files and realizes you never actually imported lodash.
Leaving it in inflates your node_modules by megabytes, and if accidentally imported, inflates your users' download by 25.3kB.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Treat unused-dependency reports as review candidates; account for scripts, tooling and dynamic references.
- Dead dependencies slow down CI builds and increase security risks.
- Use package-size estimates for comparison and measure the actual production bundle for application impact.
- sideEffects metadata guides optimization; it is not a guarantee that all code disappears or that required effects are preserved.
Done with this concept?
Mark it complete to track your progress. No login needed.