▲ | gwd 12 hours ago | |||||||||||||||||||||||||||||||
> only to discover it doesn't include the fields you want anyway because it is assuming it should only be used for the specific table UI It sounds like you're complaining that a server isn't shipping bits that it knows the client isn't going to use? > wasting bandwidth for UI which could be defined once in JS and cached is annoying How much smaller is the data encoded as JSON than the same data encoded as an HTML table? Particularly if compression is enabled? ETA: And even more so, if the JSON has fields which the client is just throwing away anyway? What seems wasteful to me is to have the server spend CPU cycles rendering data into JSON, only to have the front-end decode from JSON into internal JS representation, then back into HTML (which is then decoded back into an internal browser representation before being painted on the screen). Seems better to just render it into HTML on the server side, if you know what it's going to look like. The main advantage of using JSON would be to allow non-HTML-based clients to use the same API endpoints. But with everyone using electron these days, that's less of an issue. | ||||||||||||||||||||||||||||||||
▲ | coneonthefloor 12 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||
> What seems wasteful to me is to have the server spend CPU cycles rendering data into JSON, only to have the front-end decode from JSON into internal JS representation, then back into HTML (which is then decoded back into an internal browser representation before being painted on the screen). Seems better to just render it into HTML on the server side, if you know what it's going to look like. Well put. I think the main issue is that we have a generation of "front end engineers" who have only ever worked with javascript apps. They have no experience of how easy it is to write html and send it via a server. The same html works now, worked 20 years ago, and will work 20 years from now. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
▲ | javcasas 12 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||
> How much smaller is the data encoded as JSON than the same data encoded as an HTML table? Particularly if compression is enabled? Well, as many things in life, it depends. If the cells are just text, there is no much difference. But, if the cells are components (for example, popover things or custom buttons that redirect to other parts of the site), the difference of not shipping all those components per cell and rendering them on the frontend starts to become noticeable. | ||||||||||||||||||||||||||||||||
|