Almost every modern web application somehow interacts with a backend - be it loading data, doing background sync, submitting a form, or publishing the metrics.
Making API requests is not an easy task - we have to consider multiple outcomes and handle them properly. Otherwise, we might end up with confused users and
decreased conversion. Although the stakes are high, it is still very likely to encounter an application designed with only a happy path scenario in
mind. The question is - how can we improve it?
Let me start with a story. Once upon a time I stumbled upon an excellent
article by Philip Walton where he describes how expensive
script evaluations could (and should!) be deferred until the browser is idle or they are actually needed. One of the
examples that awakened my interest was creating an instance of the Intl.DateTimeFormat object, as I was using this
great API quite often but never thought it can cause real performance problems. Turns out it can, especially if
used inside loops. Apart from the technique
described in Philip’s article, another solution is to simply reuse Intl.DateTimeFormat instances instead of creating
them every time.
Front-end developer who’s responsible for notifications in Allegro (sometimes also from the back-end side). Interested in topics related to web performance, usability and accessibility. After hours he likes getting lost in the woods practicing orienteering.