Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual DOM is too coupled to Yew Framework #758

Open
jstarry opened this issue Nov 28, 2019 · 7 comments
Open

Virtual DOM is too coupled to Yew Framework #758

jstarry opened this issue Nov 28, 2019 · 7 comments
Labels
A-yew Area: The main yew crate breaking change feature-request A feature request

Comments

@jstarry
Copy link
Member

jstarry commented Nov 28, 2019

Description

Yew's Virtual DOM implementation is too coupled to the framework and should be moved to a different crate if possible. This would allow other backends to be used with Yew in the future.

@kellytk
Copy link
Contributor

kellytk commented Nov 29, 2019

Related issues matching "vdom": #482, #126

@kellytk
Copy link
Contributor

kellytk commented Dec 10, 2019

Related issues: #343, #324

@pickfire
Copy link

Is there anyway for yew to not use virtual DOM like dominator? What are the implications of not using it? It felt like GC (initial rust) vs no GC (current rust) to me.

@teymour-aldridge
Copy link
Contributor

Everything in Yew is pretty tied to the virtual DOM, but I've been trying to think of ways to move away from using a virtual DOM.

@rchavezj
Copy link

I don't how svelte does it but they created a declarative javascript language that gets compiled to efficient vanilla js imperative code with no virtual dom.

I would imagine looking inside the svelte's compiler as a starting point to go from rust+wasm to efficient vanilla js with wasm

@ranile
Copy link
Member

ranile commented Oct 10, 2021

I don't how svelte does it but they created a declarative javascript language that gets compiled to efficient vanilla js imperative code with no virtual dom.

I would imagine looking inside the svelte's compiler as a starting point to go from rust+wasm to efficient vanilla js with wasm

The problem with going that way in WASM is that making DOM API calls is more expensive than querying in-memory VDOM. For write operations to the DOM, this isn't an issue but for read operations (such as for diffing, etc), this can cause performance issues.
PS: I haven't benchmarked anything.

@ranile ranile added A-yew Area: The main yew crate breaking change labels Nov 24, 2021
@ranile ranile added this to the v0.19 milestone Nov 24, 2021
@ranile ranile removed this from the v0.20 milestone Apr 6, 2022
@andersk
Copy link

andersk commented Jul 16, 2022

The problem with going that way in WASM is that making DOM API calls is more expensive than querying in-memory VDOM.

The alternative to diffing with a virtual DOM isn’t diffing with the real DOM. (Well that is an alternative, but yes, it’d be very slow.) The way the fastest modern JS frameworks work is by remembering the graph of dependencies from individual DOM nodes to individual pieces of reactive state, and using it to directly update only the affected DOM nodes when some of the state changes.

This of course has implications for the API, which has to be adjusted to allow these dependencies to be tracked. This ten-minute SolidJS introduction is worth watching to understand how that could work in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate breaking change feature-request A feature request
Projects
None yet
Development

No branches or pull requests

7 participants