Skip to content
Painter
Guides

Splitting a bundle by route, carefully

Route-level splitting is the easiest win in the bundler and the easiest way to make navigation feel worse.

Splitting by route sounds obviously correct: nobody downloads the checkout to read an article. The catch is that the split moves the cost from load to navigation, and navigation has no spinner budget.

Prefetch the next likely route on idle and the trade disappears. Skip that step and you have made every click slower to make the first paint faster.

// Prefetch on hover, cancel if they leave.
link.addEventListener('pointerenter', () => import('./routes/checkout.js'), { once: true });

Do not split below the route

Component-level splitting adds request overhead and rarely repays it. Route boundaries are natural; component boundaries are not.

Leave a comment

Real questions get real answers. The editorial team reads every thread.