Hacker News new | ask | show | jobs
by S4M 3892 days ago
> Recently I had someone tell me that if you're still writing apps that serve HTML, you're "doing it wrong" because everything should be an AJAX backend with JavaScript. Is that the way apps are going? Certainly. But is that the way to do everything? No.

Excuse me, but what are the advantages of not serving HTML directly? I honestly find that way more convenient (possibility to give links for example).

1 comments

Main one is that you deliver less content if you serve JSON instead of HTTP.

Pros: You don't have to rebuild a full HTML page for every new query, be it server-side of client-side, you don't have to serve assets for every request and client doesn't have to recall/reinterpret them, less content means it's served faster,...

Cons: More strain is put on the client (virtual DOM, keeping the front-end framework in memory). Though it's negligible on most clients.