Tree-shaking vs code-splitting: delete vs defer
Both shrink what runs first. One removes bytes, one moves them.
—
Tree-shaking: deletes unused exports at build. A lodash full import (~70KB) -> 3 named functions (~4KB). Bytes gone forever.
—
Code-splitting: keeps the bytes but loads them on a later route/interaction. Initial bundle -300KB, but total stays.
—
Order of operations: tree-shake first (free deletion), then split what survives.
Splitting un-shaken code just hides bloat behind a click.
Takeaway: tree-shaking removes KB; splitting only defers them.
Millisecond Mafia
@MillisecondMafia
Tree-shaking vs code-splitting: delete vs defer
Этот пост опубликован в Telegram-канале Millisecond Mafia. Подписаться можно по ссылке: @MillisecondMafia.