DOM DocumentFragment Interface
A DocumentFragment is a lightweight container for DOM nodes that isn't part of the page. Building elements in a fragment and adding it in one go is efficient.
Description
A DocumentFragment is a minimal document object with no parent: a place to build a group of nodes off-screen. When you append a fragment to the page, its children are moved in and the fragment is left empty. Adding many elements through a single fragment means the page is only updated once.
Create one with document.createDocumentFragment() or new DocumentFragment(). The content of a <template> element is also a fragment, which you can clone with cloneNode(true).
Fragments are also used by the <template> element, whose content property holds an inert fragment: scripts don't run, images don't load and styles don't apply until a copy is inserted into the page. Like documents, fragments support querySelector(), querySelectorAll(), getElementById(), append() and prepend(), so you can find and change content inside them before inserting it.
Inheritance
DocumentFragment inherits properties and methods from Node.
Example
Browser Support
The following information will show you the current browser support for the DocumentFragment interface. Hover over a browser icon to see the version that first introduced support for this interface.
Desktop





Tablets & Mobile





