5 ms·
Technically, even if you render outside the visible area you still incur reflows/repaints. A fragment isn't rendered at all, but lets you build the entire colle
by trebor 14y ago
Technically, even if you render outside the visible area you still incur reflows/repaints. A fragment isn't rendered at all, but lets you build the entire collection as HTML once then do just one reflow/repaint to add the whole fragment to the DOM.
- elving 14y agoThis --^ Great answer!
- wwarnerandrew 14y agoWhat about using something like jquery detach? Then you could, when rendering, detach the element, render all the content, subviews, and re-append it. That shouldn't trigger reflows, right?
- trebor 14y agoCorrect. So far as I know, the way jQuery detach works is to remove it from the DOM and then return the individual element. The element could act as a fragment, because it can contain children, and then be reappended to the DOM.
- dmethvin 14y agoRight, and even better than a document fragment since fragments have both unusual semantics and API limitations that normal elements do not (e.g., no getElementsByTagName or getElementById).