Code splitting: what to get right first
This is cheap to get right at the start and expensive to retrofit. If you only fix one thing about code splitting this quarter, make it the first item below.
Speed is a feature people notice only in its absence, and then they leave rather than complain. Most teams find the first pass takes an afternoon and the maintenance takes minutes a month.
Start here
Ship the code for this page, not for every page. The reasoning matters more than the rule, because the rule has exceptions. Assume whoever inherits this will have half your context and none of your patience.
Then this
Route-level splitting is the easiest win. Small and consistent beats large and occasional here. Doing this properly once is usually cheaper than doing it approximately three times.
Eventually
Measure first, because splitting adds requests. None of that requires a large budget, only a decision and someone to own it. The failure mode is not doing it wrong, it is doing it once and assuming it stays done.
The short version
Real-world numbers from actual visitors matter more than a score produced on a fast laptop. Three things worth confirming about code splitting before you move on:
- Someone can say what the current setup is without going to look
- Ship the code for this page, not for every page — and you know whether that is true here
- There is a way to tell whether the last change to this helped
Most of the value here comes from doing the first two things, not all of them.