The Hidden Cost of String Interning in Modern Bundlers
String interning—reusing a single instance of identical strings across a bundle—feels like a no-brainer optimization. Less memory, smaller bundles, faster parsing. But in practice, the gains are often marginal, and the costs can be surprisingly high. This guide looks at when interning pays off, when it backfires, and how to evaluate it in your own projects. Why String Interning Deserves Scrutiny Now Modern bundlers have become incredibly aggressive about deduplication. Webpack's optimization.concatenateModules , Rollup's tree-shaking, and esbuild's built-in interning all aim to eliminate redundancy. For string literals, the logic is straightforward: if two modules reference the same string constant, the bundler can replace both with a shared reference. This reduces bundle size and improves cache locality. But the landscape has shifted. Code splitting, dynamic imports, and micro-frontends mean that strings are no longer static.