4 ms·
DOM already has a "batching" interface: construct an arbitrary complex new node off-screen, then use eg. replaceChild() on the live DOM (possibly using importNo
by tannhaeuser 7y ago
DOM already has a "batching" interface: construct an arbitrary complex new node off-screen, then use eg. replaceChild() on the live DOM (possibly using importNode()/adoptNode()) to attach it as the last step of your event handler.
- lhorie 7y agoThat has two problems: 1) this technique doesn't work if you need to keep part of the DOM (e.g. a focused input or a running video) 2) this technique is O(n) in IE
- jlokier 7y agoThis technique should be O(n) in every browser (where n is the size of the inserted tree), unless large parts of the tree are hidden with display:none. After replaceChild(), the inserted tree must be analysed in context for CSS, layout and rendering. That will take O(n) unless parts can be skipped. Do you mean that IE does a separate CSS or layout calculation for each node as they are inserted one by one?