DocumentFragment
A lightweight container for DOM nodes that is not part of the page, used to build many nodes and insert them all in one step.
In more detail
Changes to a fragment cause no layout, because it is off-screen. Appending the fragment moves all its children into the page at once and leaves the fragment empty. Template content is also a DocumentFragment.
Related terms
- appendChild() — The DOM method that inserts a node as the last child of an element, moving it if it was already somewhere else.
- template element — An HTML element whose contents are parsed but not rendered or run, kept as a reusable blueprint that scripts copy into the page.
- batching — Doing many similar pieces of work together in one operation, such as loading all needed owners with one query instead of one query each.
Taught in
- Modern DOM Querying: querySelector, closest And matches — Frontend Architecture & Web Platform
- DOM Manipulation: DocumentFragment And HTML Templates — Frontend Architecture & Web Platform