"매 byte 매 less 매 user time 매 less". Bundle size optimization은 production JS/CSS payload를 줄여 LCP/INP/TBT 개선 + mobile-first user 의 perceived speed 개선. 2026 standard tooling: Vite + Rollup tree-shaking, modern bundle analysis (Bundle Buddy, esbuild-visualizer), bundle budgets enforcement.
매 핵심
매 4 lever
Tree shaking: ESM only, sideEffects:false, no re-export wildcards.
Code splitting: route / component lazy import.
Compression: brotli > gzip; precompress at build.
Dependency surgery: heavy lib → lighter alt or self-implement.
// X moment (~290KB)
importmomentfrom'moment';moment().format('YYYY-MM-DD');// O Intl (built-in, 0KB)
newIntl.DateTimeFormat('en-CA').format(newDate());// O date-fns/format (tree-shakeable, ~3KB)
import{format}from'date-fns/format';format(newDate(),'yyyy-MM-dd');
sideEffects flag
// package.json — library author 측
{"name":"my-lib","type":"module","sideEffects":false,"exports":{".":{"import":"./dist/index.mjs","types":"./dist/index.d.ts"}}}