Dabish Digital
Performance

A short guide to code splitting

It comes up on almost every project, usually later than it should. Everything we would tell a client about code splitting in the time it takes to drink a coffee.

Real-world numbers from actual visitors matter more than a score produced on a fast laptop. Write the reasoning down alongside the decision, because the reasoning is what changes first.

What it costs to ignore

Ship the code for this page, not for every page. That sounds obvious written down. It is still the thing most often skipped. The version that survives contact with a real deadline is the simple one.

Where to start

Route-level splitting is the easiest win. Where this goes wrong is almost never a lack of knowledge. It is worth deciding this deliberately rather than inheriting whatever the last person set up.

Warning signs

Measure first, because splitting adds requests. None of that requires a large budget, only a decision and someone to own it. Write the reasoning down alongside the decision, because the reasoning is what changes first.

The short version

Speed is a feature people notice only in its absence, and then they leave rather than complain. 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.