Tree shaking is a build‑time optimisation technique that removes unused JavaScript code from a bundle. It isn’t a runtime process but a static analysis performed during bundling, discarding dead code so the final files are smaller and load faster for visitors.