Re:Htmx Is the Future
by jdthedisciple on Saturday May 06, 2023 @07:22AM
(#35840231)
Insofar as only retrieving data and returning it as json is way less work for the server than retrieving data plus rendering it.
[ Parent
| on HN ]
For the same data, why should serializing it to JSON be particularly faster than rendering it as HTML? The server is converting the data directly to a byte string in either case, which is about the same amount of work.
HTML is more verbose, so I would guess that JSON serialization is slightly faster, but I doubt there's an order of magnitude difference. (I could be proven wrong though)
I agree that taking HTMX to the extreme where _all_ interactions require a request to the server is too much overhead for interactive web apps. But there's likely a good middle ground where I can have mainly server side rendering of HTML fragments with a small amount of client side state/code that doesn't incur particularly more or less server load.