A Tip for Properly Handling Loading States in Web Apps

This isn’t something I was going to blog about, but after seeing the same issue a few times recently (although to be fair, last in a mobile game), I thought I’d share it with my audience. I apologize if the title isn’t the best as it was a hard issue to describe, so let me begin by demonstrating the problem, and then the (hopefully) obvious solution. Loading Data # Here’s a super simple example of a web page that loads some data from the API. In this case, it’s the Star Wars API which, unfortunately, has been pretty slow recently. On the flip side, that helps illustrate that issue. The HTML is just an h2 and an empty ul and the JavaScript is fairly simple: document.addEventListener('DOMContentLoaded',... more →
Posted in: JavaScript