
Tree Shaking
Pulls in tree shaking patterns to help you eliminate dead code from your JavaScript bundles. This is the skill to use when you're importing from libraries but only using a fraction of what they export, and your bundle size is bloating. It teaches ES2015 module syntax requirements, the difference between named and wildcard imports, and how to mark packages as side-effect-free in package.json. The content from patterns.dev does a solid job explaining how bundlers like webpack treat your code as a graph and traverse from entry points. One thing to internalize: side effects break everything, so understanding when imported code touches global scope matters more than you'd think.
- skills.sh installs
- 1.6K
- GitHub stars
- 258
- last updated
- Aug 21, 2026
Install
$ npx -y skills add patternsdev/skills --skill tree-shaking --agent claude-codeInstalls into .claude/skills of the current project.
Files
Tree Shaking
It can happen that we add code to our bundle that isn't used anywhere in our application. This piece of dead code can be eliminated in order to reduce the size of the bundle, and prevent unnecessarily loading more data! The process of eliminating dead code before adding it to our bundle, is called tree-shaking.
When to Use
- Use this when your bundle includes unused code from imported modules
- This is helpful for keeping JavaScript bundles lean and improving load performance
Instructions
- Use ES2015
import/exportsyntax — only ES modules can be tree-shaken - Use named imports instead of importing entire modules to enable effective tree-shaking
- Mark packages as side-effect-free in
package.jsonwhen appropriate - Be aware that modules with side effects cannot be safely tree-shaken
Details
Concepts
Sponsors
Details
- Repository
- github.com/patternsdev/skills
- Category
- DevOps & CI/CD
- First seen
- Jun 3, 2026
More from patternsdev/skills
All 47- Prpl1.6K
- Static Import1.6K
- Hooks Pattern1.2K
- React Composition 20261.2K
- Presentational Container Pattern1.2K
- React Render Optimization1.1K
- React Data Fetching1.1K
- Compound Pattern1.1K
- Hoc Pattern1.1K
- Client Side Rendering1.1K
- Render Props Pattern1.1K
- React Server Components1K
- Progressive Hydration1K
- React Selective Hydration1K
- Server Side Rendering997
- Incremental Static Rendering979
- Static Rendering965
- Streaming Ssr938
- Js Performance Patterns706
- View Transitions699
- Vite Bundle Optimization683
- Command Pattern660
- Observer Pattern653
- Singleton Pattern651