Back to blogs
@Ahmed Abdalla
·Web Optimization
5 mins

What is Tree Shaking in JavaScript?

Published recently

Tree shaking is a dead-code elimination technique used in modern JavaScript bundlers like Webpack and Rollup. It helps reduce bundle size by removing unused exports from your code during the build process. ES6 modules are static, which makes it easier for bundlers to analyze and safely eliminate unused code. For example, if you import only specific functions from a utility library, tree shaking ensures that only those parts are included in the final bundle. This results in faster load times and better performance.