3 ms·
> In practice, it still re-renders a lot. Neither framework will fix programmer's errors. This for(let child of container) child.innerHTML = getHtml
by c-smile 3y ago
> In practice, it still re-renders a lot.
Neither framework will fix programmer's errors.
This
for(let child of container)
child.innerHTML = getHtmlFor(i++);
will always be slower than this:
for(let i = 0; i < N; ++i)
html += getHtmlFor(i++);
container.innerHTML = html;
N transactions versus 1 transaction.
I mean that compiling separate N "small" DOM access calls is not always faster than one integral update.
- acdha 3y agoMy point was that that is enormously slower than storing a reference to the elements when you create them and setting only the specific attributes which changed. innerHtml string parsing forces the browser to do too much work unless you’re literally changing everything. Each time I’ve replaced that with DOM operations it’s been an order of magnitude or more performance gain - on one project, getting rid of fully-optimized React was 4 orders, but I think they’ve optimized it enough since then that it’s only 1-2.