Skip to main content

Frontend engineering · Performance

Tree Shaking

Also called: Dead code elimination, Shake unused exports, Unused export removal

During bundling, drop exports that nothing references so the final artifact is smaller—needs statically analyzable ES modules.

In detail

Tree shaking drops unused leaves: if you only import formatDate from a util library, other functions ideally never ship. It relies on static import/export; dynamic CommonJS require often can't be shaken.

Libraries with top-level side effects are hard to shake. Apps should avoid import * as _ from "lodash"-style pulls; prefer per-function entry points or shake-friendly libraries.

Unlike code splitting (load later), tree shaking deletes what isn't needed at all.

Developer info
Term ID
eng-tree-shaking
DOM selectors
No DOM cues. This concept isn't detected directly on a page.
Priority
1 · when several match at the same level, the higher priority wins
Version
v1 · updated Oct 5, 2026