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

Optimize static vNode trees #1413

Open
Havunen opened this issue Nov 2, 2018 · 2 comments
Open

Optimize static vNode trees #1413

Havunen opened this issue Nov 2, 2018 · 2 comments

Comments

@Havunen
Copy link
Member

Havunen commented Nov 2, 2018

We could detect static vNode trees during compilation time ( JSX ).

Some idea how this could work:

When static shape is detected. See infernojs/babel-plugin-inferno#54
We hoist the given vNode tree and flag it as Static.
Now during patch algorithm, when two identical vNodes are diffed we check if the shape has been marked as static we just return. This static flag could be used also to mount faster. For example when static vNode has been flagged and this vNode comes to mount routine, we check if it already contains dom, now if it returns a dom, we clone the vNode using directClone or deepClone and clone the actual DOM tree using dom.cloneNode(true). This way the whole tree can be created much faster.

This algorithm will not improve the performance for everybody, because there is usually a lot dynamic information in real single page applications, but it will benefit some apps.

@farooqkz
Copy link

Is this feature request still valid?

@Havunen
Copy link
Member Author

Havunen commented Nov 15, 2022

Yep,

I tried to implement it for v8, but encountered some edge-cases which were failing.

Here is the link to inferno repo: https://github.com/infernojs/inferno/tree/static-vnode-optimization

Also babel plugin has similar branch with changes to automatically detect static trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants