3 ms·
You would think that diffing is inefficient, but apparently modifying the DOM is significantly more inefficient. Mithril -- the framework that inspired this exa
by robertakarobin 7y ago
You would think that diffing is inefficient, but apparently modifying the DOM is significantly more inefficient. Mithril -- the framework that inspired this example -- has an interesting take: https://mithril.js.org/vnodes.html https://mithril.js.org/vnodes.html
- websitescenes 7y agoI think he means that this snippet of code doesn’t account for diffing like React does and would fail if scaled out. I think the OP is aware of that though.
- TheRealPomax 7y agoAs a 33 line implementation "just for fun" exercise, no need to guess: this was not meant to be actual React in fewer lines of code =)
- seanwilson 7y agoI don't know how React does it so it was a genuine question. I'm assuming they do some smart diffing to be more efficient. It'll be irrelevant for most apps but I'm curious how much less efficient all this is compared to (in CPU time, not developer time) updating the DOM directly e.g with: document.querySelector('.timer').textContent = "5 seconds"