logoalt Hacker News

stefan_last Thursday at 3:41 PM3 repliesview on HN

It's terrible, why would I want my endpoints to return random HTML fragments? I realize thats how you did it in the JQuery times, but I was never in those - at that time we simply had template engines in the backend so this HTML slop wouldn't contaminate everywhere..

Most of the frontend stuff I do is for internal pages on embedded devices, and I'm very happy with a structure where I have the frontend being a full React fancy component lib SPA that is eventually just compiled down to a zip bundle of files that the backend needs to know nothing about and can serve as dumb files. The backend is a JSON API of sorts that I would need to build anyway for other use cases.


Replies

bottlepalmlast Thursday at 5:49 PM

Returning HTML sounds like a styling nightmare, if anyone changes the structure, unintended consequences. Plus it’s difficult to reason possible states of the UI with fragments sitting on the server, possibly dynamically built on the server. Very jquery/PHP ish. I had my fun and don’t want to go back.

show 2 replies
drcongolast Thursday at 4:08 PM

The HTML fragments aren't random.

ErroneousBoshlast Thursday at 3:46 PM

> It's terrible, why would I want my endpoints to return random HTML fragments?

What would you return instead? It's easy to generate HTML, because that's what your server is already generating (and that's about all it should generate).

show 1 reply