NervJS / nerv

A blazing fast React alternative, compatible with IE8 and React 16.
https://nerv.aotu.io
MIT License
5.42k stars 267 forks source link

Hydration Removing All Children #14

Open thysultan opened 6 years ago

thysultan commented 6 years ago

The hydrate function seems to be removing all children indiscriminately.

hydrate.ts#L4-L16

The ReactDOM version of hydrate works by hydrating the existing markup, attempts to attach event listeners to the existing markup and fixes mismatched text content where appropriate.

yuche commented 6 years ago

In our research clear the children and mount just slightly slower than React way hydration , instead the size of the package will go much bigger. (maybe we are doing it wrong)

Anyway, that's a good feature. but we need more time to figure out how to implementing this with less cost.

dzek69 commented 6 years ago

It (clearing instead of reusing) may be a performance hit on really big sites I guess. Still - having this as an option would be awesome.

So I would decide if hydrating 30ms faster is worth downloading xx kb of code, because there is a chance that parsing more code (by JS engine) would take additional 10ms and downloading it would take 20ms and I'm saving nothing in result.