Live data from Hacker News

You don't need React: creating a minimal UI library in Vanilla JavaScript

pedroth.github.io

11–20 of 117 posts

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#11
post #4

> The only potential issue with immediate mode is performance, since we need to re-render the entire UI on every state change. How this made it to HN front page?

I think the author is saying a potential issue of a vanilla implementation of immediate mode. The following text explains that there is already many optimizations for this

Nothing in HTML is immediate mode. Any framework with a DOM is retained mode, by definition.

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#15
post #11

Earlier quoted context omitted.

I think the author is saying a potential issue of a vanilla implementation of immediate mode. The following text explains that there is already many optimizations for this

Nothing in HTML is immediate mode. Any framework with a DOM is retained mode, by definition.

But the api is trying to simulate immediate mode using DOM

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#16
post #7

> immediate mode You keep using that word. I do not think it means what you think it means. React most definitely falls under what would be called a "retained mode" of some sort. And the UI library described here is also.

I think the author is referring to immediate mode because of

UI=f(state)

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#18
post #11

Earlier quoted context omitted.

Nothing in HTML is immediate mode. Any framework with a DOM is retained mode, by definition.

But the api is trying to simulate immediate mode using DOM

That's called an "abomination". The advantage of immediate mode is not storing a DOM. If you write immediate-mode code but it stores a DOM anyway then it's the worst of both worlds.

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#19

I agree that React gets overused for many websites, but I'm not sure about this project over something like Astro. I built an Astro Starter that uses just CSS in a scalable way for simple websites. Content is written in Markdown / MDX files. Design tokens are set in var.css. Other stuff is defined in one config.ts file. Global styling is set though a few CSS files (Global, Reset, Var, Util, Markdown), components are…

[deleted]

Re: You don't need React: creating a minimal UI library in Vanilla JavaScript

#20
I think React is way overused but every time you see a blog post with "replace it with this pet mini project instead" I groan because you know the reaction is going to be "what about X feature", and of course the mini framework doesn't do it.

I've found the perfect balance to be Astro with Preact. You will inevitably have some piece of functionality that's complex (say, a contact form) and you can lean into Preact for that. But for the vast majority of a content-heavy site you can just use Astro and skip the client-side bulk entirely.

STANDARD DISCLAIMER ANY TIME I COMMENT ON FRONT END DEV: your project may be different. A blog or a shopping site and have extremely different requirements to a full Gmail-style web app. There does not need to be a one size fits all answer.

Post reply on HN