JavaScriptMedium
Explain the concept of tree shaking in module bundling
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
Tree shaking is a technique used in module bundling to eliminate dead code, which is code that is never used or executed. This helps to reduce the final bundle size and improve application performance. It works by analyzing the dependency graph of the code and removing any unused exports. Tools like Webpack and Rollup support tree shaking when using ES6 module syntax (import and export).
