Minification vs Tree Shaking
Both make code files smaller. Minification squeezes code by cutting spaces and long names. Tree shaking drops whole parts of code that are never used.
Minification
Making code smaller. It cuts spaces, notes and long names, and the code still works.
Minification makes code files smaller. It removes all the things the computer does not need. It strips spaces, line breaks and comments, and it swaps long names for one letter. The code still runs the same, but it is hard for people to read. Smaller files download faster, which matters most on phones. Build tools minify JavaScript and CSS before a site goes live.
Tree Shaking
A build step that drops code you imported but never used.
Tree shaking is a build step that removes code you import but never use. A bundler follows which functions each file really calls. Anything that is never reached is left out of the final bundle. This matters because big libraries may hold hundreds of functions when you use three. It works best with modern import and export syntax.
In one line
- Minification
- Making code smaller. It cuts spaces, notes and long names, and the code still works.
- Tree Shaking
- A build step that drops code you imported but never used.