Live data from Hacker News

Hydration is pure overhead

builder.io

41–50 of 84 posts

Re: Hydration is pure overhead

#41
post #25

Earlier quoted context omitted.

I've been brainwashed by consumers – they demand and expect a certain experience on the modern web. Also, you can run Next.js on a Raspberry Pi and free Cloudflare DNS+SSL. :shrug:

what are their demands? pretty sure my Raspberry Pi will just give up after pulling 2000 npm packages and building native modules

You're wrong. I used to run node + mongo on my 3B+ until it died on me one last time :(

It could manage much, much more than that. Now, I haven't tried running Next on it but unless it's worse than Nuxt (which isn't all that fast, really), it should be fine.

These little SBCs are only lacking at GPU tasks

Re: Hydration is pure overhead

#42
post #16

Earlier quoted context omitted.

the reason we need all this is so that Netlify and Vercel can make money there’s no other explanation it’s a capitalist game and if you want to stay sane, you shouldn’t play it

> there’s no other explanation Faster initial load times for PWAs? No conspiracy theory or capitalism rant needed.

Isomorphic (the same js libraries on the server & client) software is also nice. With WASM, it is possible with other programming languages, though js/ts has a large head start in the isomorphic web space.

Re: Hydration is pure overhead

#43
post #41
post #25

Earlier quoted context omitted.

what are their demands? pretty sure my Raspberry Pi will just give up after pulling 2000 npm packages and building native modules

You're wrong. I used to run node + mongo on my 3B+ until it died on me one last time :( It could manage much, much more than that. Now, I haven't tried running Next on it but unless it's worse than Nuxt (which isn't all that fast, really), it should be fine. These little SBCs are only lacking at GPU tasks

have you tried using a compiled language and a database that isn’t web-scale?

this should fix your dead board /s

Re: Hydration is pure overhead

#44

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.

Not that irrelevant.

Traditional SSR involved a separation between templates which contain presentation logic, and controllers for mediating business logic, persistence etc.

If your backend & frontend are in same language, or you use template engines with implementations in mutliple language like handlebars/pug/soy etc. you could easily render the same templates using JS and your client side can have as much ui state, interactivity etc. as you want.

If we adopt incremental enhancement then the fetching of templates can be delayed - we primarily need the controllers which handle dom events to make the server-rendered ui interactive. This is easily achievable through libraries like stimulus where controllers can add complex interactivity to server rendered templates and re-render them if needed through templates which are fetched on demand. We can even preserve form element states by using libraries like morphdom for swapping content.

However, what really breaks down all of the above is the concept of components as popularized by React etc. When we start writing react-style components then our rendering logic and associated behavior are tightly coupled and we need to pull in all the rendering logic for enhancing the server rendered content. React devs like to preach that traditional separation of concerns is not useful in practice and it is better to have rendering code colocated with behavior - but solutions like this just demonstrate that this separation did actually have some merit albeit at the cost of some indirection.

What solutions like Qwik are attempting to do is enabling folks to keep writing component oriented code but now we need a fancy compiler tooling that deeply integrates with the stack. The approach does have its merits but it is just one path to address the problem.

Re: Hydration is pure overhead

#45
post #4

This is confusing to me. From the article it sounds like the javascript is run on the server producing markup. That markup is sent to the browser for rendering then the javascript is requested by the browser. When the javascript arrives it is run again on the browser to re-generate the DOM with event handlers attached. If that is correct then why is the javascript run on the server to begin with and not just sent dir…

This post is part of a broader effort among emerging js frameworks to send less code down to the browser. It's not just bandwidth. The time to parse, compile, and execute the JS can take as long on a phone as the download itself For a decent fraction of applications a large chunk of the code that's written is to generate non-interactive parts of the app (data fetching, wrappers, component markup, CSS) and the actual…

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 chunks of the UI rather than just URLs.

Re: Hydration is pure overhead

#46
While we are on the topic of browser event handlers and "embracing how browser actually work", I can't help but mention that the builder.io website's top navbar cannot handle ctrl + clicking (for opening links in a new tab).

It's actually quite subtle. Sometimes it works, sometimes it doesn't, depending on which page you are on, what you've already clicked, etc. All part of the fun of frontend web development, ain't it?

Re: Hydration is pure overhead

#47
post #5

Quoted post unavailable.

I've been brainwashed by consumers – they demand and expect a certain experience on the modern web. Also, you can run Next.js on a Raspberry Pi and free Cloudflare DNS+SSL. :shrug:

The fallacy of our generation. Except they literally don't. They just don't want their computer to not run out of battery loading your resume driven developed site.

Re: Hydration is pure overhead

#48
post #4

This is confusing to me. From the article it sounds like the javascript is run on the server producing markup. That markup is sent to the browser for rendering then the javascript is requested by the browser. When the javascript arrives it is run again on the browser to re-generate the DOM with event handlers attached. If that is correct then why is the javascript run on the server to begin with and not just sent dir…

> If that is correct then why is the javascript run on the server to begin with and not just sent directly to the browser? Just the same ordinary reasons to generate HTML on the server: it allows you to support HTTP caching (in a CDN or even browser caching), it (potentially) lets the browser start rendering content much sooner, and it will be viewable by user agents (bots, scrapers, search engines, etc., but also hu…

that makes sense, so if you're using http caching appropriately the server side "render" or running of the javascript happens on the first visit and then infrequently thereafter.

Re: Hydration is pure overhead

#49
post #43
post #41

Earlier quoted context omitted.

You're wrong. I used to run node + mongo on my 3B+ until it died on me one last time :( It could manage much, much more than that. Now, I haven't tried running Next on it but unless it's worse than Nuxt (which isn't all that fast, really), it should be fine. These little SBCs are only lacking at GPU tasks

have you tried using a compiled language and a database that isn’t web-scale? this should fix your dead board /s

No, I am not manly enough :(

Pretty sad about it dying on me, though. This time it wasn't just a borked flash card.

Been waiting for a 5 but it's taking ages

Re: Hydration is pure overhead

#50
post #4

This is confusing to me. From the article it sounds like the javascript is run on the server producing markup. That markup is sent to the browser for rendering then the javascript is requested by the browser. When the javascript arrives it is run again on the browser to re-generate the DOM with event handlers attached. If that is correct then why is the javascript run on the server to begin with and not just sent dir…

Generally speaking, if you approach qwik.js from a 10,000 mile view like you'd normally approach other frameworks, you're going to miss the trees for the forest. One of the axioms where this framework is coming from is the idea of providing React-like developer experience, so yes, there's going to be templates expressed in JS.

Where it gets technical has to do with how the JS gets delivered to the browser. It starts with a small bootstrapping that sets up event delegation, sort of like `document.documentElement.addEventListener('click', becomeAwareOfClicks)`. This happens literally on the first chunk of HTML being streamed in, meaning that the framework is now already aware of clicks happening anywhere in the app, even before HTML is available in JS.

Eventually some HTML will stream in with an attribute that indicates how a click event on an element should be handled. The framework can then quickly determine whether it needs to "hydrate" that event handler: a) if the event was captured by `becomeAwareOfClicks` and b) the intersection observer deems that element is visible and available to DOM manipulation, then c) it can download the relevant handler, meaning it triggers business logic at latest as soon as the intersection observer downloads the handler.

Note that at this point, no other JS has downloaded yet. Eventually it does download it, like every other framework, but the key point is that it can respond to events with actual business logic before the rest of the JS comes down the pipe.

Post reply on HN