HN2new | past | comments | ask | show | jobs | submitlogin

SPAs don't make sense if it's not an 'application', but wouldn't a SPA be faster over time not having to reload the whole page and all that duplicate markup? Wouldn't the simple JSON calls be smaller than refetching and rerendering all of the HTML? Front-end application offer more than just no-reload though, like push notifications, real-time data, and offline caches.


It’s not that simple: you need to factor in size and latency, too. If my SPA loads 2MB of JavaScript and then makes 50 API calls, it’s going to be a lot slower than the server sending 20kb of HTML in a single response.

JSON may or may not be smaller or faster: if you have to load data you don’t need or, worse, chase links it’ll be worse. GraphQL may help but that’s bringing it closer to server-side performance, not exceeding it.

Things which aren’t possible otherwise are the best argument for SPAs, but another approach is progressive enhancement: you can load quickly and then load features as needed rather than locking in a big up-front cost if all you need are real-time updates or push notifications. There’s a spectrum of capabilities here and there won’t be a single right answer for every project.


It depends, as always. (Compressed) JSON is probably smaller than (compressed) HTML, but that doesn't necessarily translate to more round trips. And browsers are pretty good at rendering HTML, and at the same time SPAs will get in the way of translating the JSON to rendered HTML on screen.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: