When JavaScript bundle size is worth the effort
Teams tend to reach for this after something has already gone wrong. JavaScript bundle size is not free, and pretending otherwise leads to bad decisions.
Code gets read far more often than it gets written, and usually by someone with less context than the author had. The version that survives contact with a real deadline is the simple one.
When it is worth it
Every kilobyte of JavaScript costs more than a kilobyte of image. In practice this is a scheduling problem more than a technical one. Check it against what you would want a competitor's site to get wrong.
When it is not
If nothing downstream depends on it and nobody is complaining, it can wait. This is the sort of thing that compounds, quietly, in both directions.
How to decide
Measure the bundle before optimising anything else. Getting it slightly wrong is survivable. Ignoring it entirely is not. Anything you cannot measure here, you are deciding by taste, which is fine as long as everyone knows it.
In practice
The question is rarely whether something can be built, but what it costs to keep running afterwards. Three things worth confirming about JavaScript bundle size before you move on:
- Someone can say what the current setup is without going to look
- Measure the bundle before optimising anything else — 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.