3 ms·
It's easy to forget that html isn't the end product, the end result is lit pixels on some screen (usually). If we send json then that needs to be converted to h
by alkonaut 11y ago
It's easy to forget that html isn't the end product, the end result is lit pixels on some screen (usually). If we send json then that needs to be converted to html and that html needs to be layout and rendered. If we send html we just skip the first step. Displaying a web page isn't "free" for the client just because it's html.
The question is this: what kind of overhead is a template rendering task (in js) for a modern browser, compared to the task of layout and rendering a finished html page? It will depend of course on the complexity of the data and the resulting page, as well as the browser, templating engine etc. I have no clue whether it's 1%, 10% or 50%.
- firasd 11y agoThe slowdown caused by JS isn’t due as much to the rendering speed as the HTTP requests.
- TeMPOraL 11y ago> It's easy to forget that html isn't the end product, the end result is lit pixels on some screen (usually). If we send json then that needs to be converted to html and that html needs to be layout and rendered. If we send html we just skip the first step. Displaying a web page isn't "free" for the client just because it's html. JSON->HTML rendering may be only one step, but by not skipping it, we're making hundred thousands computers redo the computation that could be done once on a server. This has some electricity cost aggregated over all users, which we externalize to society because of a fad. You can't really skip the HTML->pixels step because of data size issues, but there's little excuse for client-side rendering of static content.
- moonchrome 11y agoWho says you're doing JSON->HTML ? Both HTML and your data format need to get deserialized to DOM - depending on use case it can be faster/smaller to do the deserialization in JS from some format rather than using browser HTML parser. HTML is actually non-trivial to parse and isn't really optimized for anything.
- odiroot 11y agoCrazy thought: detect viewport size on first load and serve pre-rendered PNGs to skip the rendering on client part. Someone probably already developed that.
- iopq 11y agoOpera did something like this, but instead of PNGs they gave custom markup that is precomputed so that the flip phones don't have to do layout. Or something like that. Opera mobile had server farms rendering content and re-compressing large images.
- NicoJuicy 11y agoviewport size can only be detected when the page is loaded... Afterwards, the images are loaded. It feels slow ;)
- 0x4a42 11y agoWith this method the content wouldn't be accessible to user agents that are coupled to helpers for persons with disabilities.
- masklinn 11y agoThat is essentially what Opera Mini does/did: requests went through Opera's render farm which would request page and render them (with adaptations) to a packed binary format and send that back to the device. There was also rudimentary JS support in the rendering farm, the device essentially got an image with an interaction map, and interactions would be sent to the server for processing. Not very configurable though, can't really e.g. customise font size, observe the page or pass it through a screen reader.
- uptown 11y agoNot to mention the enormous privacy trade-off of having Opera monitor and screenshot every webpage you visit.
- pjc50 11y agoNo, the end product is an ad payment to the company producing and serving the articles. That's where all the junk comes from: tracking the user and trying to upsell them into a mobile app so you can get more personal data and a spot on their home screen.