Live data from Hacker News

Hydration is pure overhead

builder.io

81–84 of 84 posts

Re: Hydration is pure overhead

#81

Sometimes you just have to laugh. We've been doing SSR all along, folks: server side templates. Yeah, HTML was pretty hamstrung as a hypermedia, which made for mediocre UX, but that's been fixed by libraries like unpoly, hotwire, or, my own, htmx.

This is for enhancing CSR initial load times. For apps that need to work offline, have a lot of UI state, have sister native apps, etc. Yes we've had SSR, noone is disputing that, nor is it relevant. These are separate solutions for separate problems. I agree some people reach for the wrong tools sometimes, but that's a universal problem.

> For apps that need to work offline

I wonder if it’s a suitable approach at all for those, because when they’re offline they won’t be able to lazy-load the JS code they’re still missing.

Re: Hydration is pure overhead

#82
post #56

Earlier quoted context omitted.

I don't use React-based static site generators, but I'd imagine if they become slow it's because it's generating a large code-base, but unless you provide some benchmarks showing compilation of React vs some other templating system I can't really take your argument against it for this use case.

don’t take my word for it https://css-tricks.com/comparing-static-site-generator-build... Next.js and Gatsby are the slowest

Generating a bunch of HTML pages from markdown files doesn't seem like a remotely realistic test case for "interactive complex web applications".

Re: Hydration is pure overhead

#83
post #76
post #45

Earlier quoted context omitted.

You could avoid shipping down the JSX templates but only by promising to never render a comment on the client. That's basically the approach taken by this React Server Components proposal: https://github.com/josephsavona/rfcs/blob/server-components/... Rails has experimented with this sort of thing in the past; it requires some deep integration with the HTTP server so that clients can request updates to specific chun…

Oh my, this is what we did ~15years ago with PHP and jQuery, I was hoping no more. We really did a full circle.

I've written quite a bit of PHP and jQuery but with that approach there's a decision when you consider writing the code if you're going to implement the feature in PHP or in jQuery. The difference with the upcoming generation of JS frameworks is that the server and client are in the same language so the decision can be deferred or it can be determined automatically.

Astro, for example, is very conceptually close to PHP. Your code runs on the server, there's a code section where you grab content from the DB and a markup section where you template out the page, the lifetime of everything is one request, etc. What's changed is that you can put an attr on a component indicating you want that component sent to the client. No attr, it's old PHP, attr it's jQuery, and further the send can be triggered can be when the element enters the viewport or when it's clicked.

In the in-development Marko 6 runtime distinguishes between url/db derived "settled" data and client side/event handler state and only sends the latter to the client. If you have a paged list (for example) you can set up the prev/next page buttons to be links and you wouldn't have any JS sent down to the client despite the app being written with current SPA component ergonomics. If you'd rather have the data fetch and render client side you switch the data declaration from a const (dervied/settled) to a let (state) and all the rendering JS gets sent down.

I'm simplifying/omitting stuff but these are new and useful takes on old ideas. I think better takes on old ideas are some of the more effective advances in the state of the art.

Re: Hydration is pure overhead

#84
post #78

Earlier quoted context omitted.

don't forget LiveView!

LiveView is easily the best implementation of this concept, shame Elixir is not more popular than it is.

I built my startup on elixir. Its allowed us to do things in days that would take weeks in nodejs. Absolutely fantastic system overall. biggest gripe is that its hard to hire for.
Post reply on HN