HTML you can render as-is. JSON needs additional processing logic client-side.
Other times, centralizing it on the server might be best.
Some apps lend themselves much more to doing a lot of interesting work on the client (Figma is an example, going so far as to implementing their own rendering engine, for instance).
tl;dr:
Your JSON api has to figure out:
- How to predict and enable all possible workflows
- How to avoid N+1 requests for awkward workflows
- How to test functionality, performance, and security of every possible request
- How to change the API without breaking the existing workflows
- How to prioritize API changes between internal and community requirements
- How to document everything so that all parties can get stuff done
And on then on the front-end, you have to figure out:
- How to collect all the data needed to render a page
- How to optimize requests to multiple endpoints
- How to avoid using API data fields in unintended ways
- How to weigh the benefit of new features against the cost of new API requests
He goes on to point out that the "re-use" value of an api endpoint is extremely low. You can re-use virtually all the code that produced that endpoint to produce a different one with a different structure for precisely what you need in this new use-case.
Then add a layer on top of that that 'renders' the same structure into multiple formats: JSON or HTML as needed.
Expose each of these view layers as a different endpoint in your service.
Also, sending json means you either need type information in two apps, OR you build without strict types in one of the ends. Either way it's more work or less resilience.
These are just two examples that focus on DX.
REST, instead of what we decided to start calling REST
Case in point for partial HTML updates: you update the backend in such a way that HTML it sends is no longer compatible with the frontends running in the browsers.
(You won’t believe how long can a page be open without a refresh.)
This project, if anything, follows a JS-on-backend-and-frontend and thus is more of a promotion of JS-everywhere than a way to "get rid of it".
Render the HTML server side instead of client side, then the client is only doing DOM updates.