DEV Community

Discussion on: Why Virtual DOM?

Collapse
 
_genjudev profile image
Larson • Edited

yes its about react. But ...

svelte.dev/blog/virtual-dom-is-pur...

Collapse
 
nevergarden profile image
Nevergarden

not only overhead it's not good for SEO

Collapse
 
aidenybai profile image
Aiden Bai

Which is why raw runtime VDOM is never used for most real websites - SSR is needed if you need SEO. Anything rendered with JavaScript is "not good for SEO"

Collapse
 
aidenybai profile image
Aiden Bai

If you read the article Lars sent, make sure to read and understand the entire article - Just reading the title is a misconception without context. Virtual DOM is generally efficient if you only have runtime, and was invented in a time when "compiler-frameworks" like Svelte didn't exist.

Collapse
 
hasnaindev profile image
Muhammad Hasnain • Edited

I agree with Aiden. Svelte is a compiler, it is very beautiful but works in a very different way. If I wanted almost zero bundle size on my personal website that needs small JS based widgets, I might go for Million... BUT!

The API provided by Million reminds me of the 2 KB library called, "re:dom". Creating a todo app in re:dom is quite something! Compared with Vue, Svelte or React, in re:dom, I need to update state and then manually pinpoint the element I want to update.

Such level of micro-management makes my life harder and I won't mind using an alternative even if it adds a few more kilobytes to the bundle. Developer experience is also very important. P.S, I've used re:dom in some of my projects to make DOM elements creation a breeze.

So, could you please include a todo app in your documentation? Let's see how different it is and how easy it would be compared to re:dom given that there is a fast effective patch method in Million?

Collapse
 
aidenybai profile image
Aiden Bai

I actually haven't heard of RE:DOM, but I just checked it out. It seems from (my very, very brief skim) that it provides a little bit of abstractions over what the DOM already is. Personally, I wouldn't call this declarative web programming, but I also probably do not understand this library enough.

Because it looks to seem like it only provides a minimal layer of abstractions, it's going to be fast - if you write basically native imperative DOM code, it's always going to be fast.

Regarding the todo example, there is a Hello World example in the README + docs, but no todo example. It will probably be easier to manage state in the libraries you mentioned than Million, but that's not the use case of Million. You can imagine Million as the "build target for a compiler." By itself, it's just a Virtual DOM, and other developers can build their own libraries, paradigms, concepts over it (with React, Vue, Svelte, other syntaxes)

Possibly once there is an ecosystem or libraries built around it, more todo examples will pop up and we can see something cool out of this. Thanks for the feedback!

Thread Thread
 
hasnaindev profile image
Muhammad Hasnain

Ooh, thanks for the clarification. I also looked into Lucia, it's a really fun tool. I love how I don't have to write any JavaScript and this 3 KB library can handle the reactivity. Honestly, you must be a genius. No doubt you will end up creating a tool that millions of us are going to use.

Thread Thread
 
aidenybai profile image
Aiden Bai

Haha, thanks for the compliment, I'm happy to help.