I’m doing some performance testing and analysis with a large amount of nodes (~1000) and the biggest hit to performance I can see is Reflows or Layout thrashing. It seems to be due to the use of getClientRects().
It was happening internally where state.scrollToSelection > prev.scrollToSelection in updateStateInner which sets a local variable scroll to equal “to selection” . This would then trigger this line to run:
I’m not sure why this is being executed on every keypress, but even if I remove it I’m seeing reflows so maybe this is inevitable if content changes. In which case there’s not much that can be done to avoid it other than making the reflow faster.
Even if the cursor is already in view? I might look into this part further and report back.
But ultimately you are right, computing layout is going to be necessary when the DOM changes. There might be things I can do on my end to make reflows cheaper however.