patternsdev avatar

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-code

Installs 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/export syntax — 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.json when 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
1adobe avatarauthoring-analysisadobe/skillsUse this when the page-import pipeline needs to determine the authoring approach (default content vs blocks) for scraped content before generating import HTML f1.6Kskills.sh installs
2adobe avatarpage-decompositionadobe/skillsUse this when the page-import pipeline needs to analyze the content sequences within a single section and describe them neutrally for AEM Edge Delivery Services1.6Kskills.sh installs
3github avatargtm-partnership-architecturegithub/awesome-copilotBuild and scale partner ecosystems that drive revenue and platform adoption. Use when building partner programs from scratch, tiering partnerships, managing co-1.6Kskills.sh installs
4nvidia avatartao-analyze-changenet-rcanvidia/skillsPerforms deep Root Cause Analysis (RCA) on NVIDIA TAO Visual ChangeNet classification experiments with image-evidence-driven investigation. Use when analyzing C1.6Kskills.sh installs
5getstream avatarstreamgetstream/agent-skillsStream router for Chat, Video, Feeds, and Moderation. Use when the user wants to build a new app with Stream, scaffold a project, add Chat/Video/Feeds/Moderatio1.6Kskills.sh installs
6nvidia avatartao-analyze-gaps-visual-changenetnvidia/skillsPerforms gap analysis on NVIDIA TAO VCN Classify (Visual Component Net) experiments by invoking the data-services container (`tao_toolkit.data_services` from `v1.6Kskills.sh installs