Cold starts, plugin gaps, and the numbers behind the decision. JavaScript gives you a dozen ways to solve the same problem, and the platform quietly added a better one while most of us were not looking. This post walks through that better way and the reasoning behind it.

The problem in one snippet
The first version of our code worked on a fast laptop and failed on a slow phone. Nothing was wrong with the logic; the timing assumptions were simply never written down, so nobody noticed when they stopped being true.
- Measure on a throttled CPU, not your laptop.
- Clean up listeners in the same place you add them.
- Treat every network call as cancellable.
- Log the slow path, not just the error path.
Wiring it into real code
Once the pattern is in place, the rest of the codebase gets simpler. Callers no longer need to remember cleanup, and the error paths are handled in one spot instead of five.
Programs must be written for people to read, and only incidentally for machines to execute.
Harold Abelson, Structure and Interpretation of Computer Programs, 1985
Quick takeaway
Write down your timing assumptions; the platform usually has an API that enforces them.
Edge cases we hit
Timeouts
Every request gets an upper bound.
Cleanup
Listeners and timers go away with the component.
Measurement
Profile on slow hardware before optimising.
Keep an eye on older browsers and on Node versions below 18, where some of these APIs are missing or behind flags. A tiny feature check at startup saves a confusing bug report later.
None of this is new, and that is the point. The techniques that last are usually the boring ones that are documented well and supported by the platform itself.
As always, the examples are simplified to fit on a page. The production version has more error handling and logging, but the shape of the code is the same.
Questions, corrections, and war stories are welcome in the comments. Several of our best follow-up posts started as a reader pointing out something we had missed.
We will revisit this in six months with fresh numbers. If the results change, we will update the post and note what changed at the end.
If you try this on your own project, start with one page or one service rather than the whole codebase. A small experiment gives you real numbers to argue with, and it is easy to roll back if the idea does not fit.
Wrapping up
We will revisit this in six months with fresh numbers. If the results change, we will update the post and note what changed at the end.
Tried it on a side project over the weekend and it worked first time, which never happens.
The renaming spree is a rite of passage.
Good question. We measured on a mid-range Android phone and took the median of five runs.
We have a follow-up on CI in the drafts, stay tuned.
How does this hold up on older Safari versions? That is where we always get burned.
Great post. Did you measure the impact before and after, or is this mostly from experience?
Solid write-up. The warning about caching bit us hard last year.
The part about naming things made me laugh, then made me go rename three functions.