Open Havunen opened 6 years ago
Is this feature request still valid?
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
We could detect static vNode trees during compilation time ( JSX ).
Some idea how this could work:
When static shape is detected. See https://github.com/infernojs/babel-plugin-inferno/issues/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 usingdom.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.