A practical checklist for code splitting
It comes up on almost every project, usually later than it should. Run through this the next time code splitting comes up.
Real-world numbers from actual visitors matter more than a score produced on a fast laptop. Doing this properly once is usually cheaper than doing it approximately three times.
The checklist
- Ship the code for this page, not for every page
- Route-level splitting is the easiest win
- Measure first, because splitting adds requests
- Someone is named as the owner
- There is a date to review it again
What is actually at stake
Ship the code for this page, not for every page. It is worth being explicit about, because assumptions differ quietly. Doing this properly once is usually cheaper than doing it approximately three times.
In practice
Performance work is mostly subtraction, which makes it unpopular and effective. Three things worth confirming about code splitting before you move on:
- Someone can say what the current setup is without going to look
- Measure first, because splitting adds requests — and you know whether that is true here
- There is a way to tell whether the last change to this helped
If you want a second opinion on how yours is set up, ask.