Tree-shaking removes unused code from compiled or bundled programs. ES modules make this possible because explicit import and export syntax exposes dependencies to static analysis. section 3.4
For an interview-ready explanation, connect the technique to its module-system prerequisites and performance effects:
- Use ES modules with explicit imports and exports so bundling tools can identify unused code. section 3.4
- Relate removal of unused code to smaller bundles and improved load times. section 3.4
- Distinguish tree-shaking from dynamic imports, which support code splitting and lazy loading by loading necessary code when needed. section 3.4




