Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 98 forks source link

This is not a virtual DOM - touching DOM too much! #40

Closed himalayafan closed 8 years ago

himalayafan commented 8 years ago

I just figured out that this is not a virtual DOM. You are touching DOM too much, both on creation and update! That's why you get your horrible performance!

One example is found in the velem prototype where you do an update. For children you are calling childNodes on a real DOM node!! An this happen on each update.

You take this childnodes and iterate over it - more expensive - BEFORE you update the node with it.

How many times you think you are touching the real DOM? Too many.

You should use the vdom object for this.

A lot of different places in your code you are doing this - touching DOM where you shouldn't.

I just compared with React. They are not doing it the same way as you are doing it!

To get the childNodes length in a virtual DOM, just count how many children there is on the vdom object without touching the DOM.

Lucifier129 commented 8 years ago

touch DOM is ok, DOM is fast, virtual-dom did'nt mean not to touch DOM.

himalayafan commented 8 years ago

Please study this https://news.ycombinator.com/item?id=9155564