Tree shaking in JavaScript is becoming an essential practice, to avoid large bundle sizes and improve performance.
The principle behind tree shaking is as follows:
1. You declare all of your imports and exports for each of your modules
2. Your bundler (Webpack, Rollup, and so on) analyze your dependency tree during the compilation step
3. Any provably unused code is dropped from the final bundle, or ‘tree-shaken’.
Läs hela artikeln på medium eller läs mer av Daniel Brain.