liveBook · Manning

DOM fragment

A DOM fragment is a lightweight, detached node that can hold a subtree of nodes independently of a document tree.

How 2 Manning books explain it

Web Components in Action

A document fragment is a lightweight DOM node that can contain a subtree of nodes without itself being part of a document tree.

How it is used
Uses fragments to assemble reusable HTML and batch DOM insertion, especially when templates or repeated content are involved.
How deep it goes
Explains construction, child movement, and insertion performance, but stops short of broader DOM implementation internals.
Examples
Demonstrates five generated paragraphs, template content cloning, and inspection of shadow roots in browser developer tools.
What you can do after
Apply it via JavaScript DOM APIs to build node groups and insert them into a document with one append operation.

Read how Web Components in Action explains DOM fragment →

Secrets of the JavaScript Ninja, Second Edition

A lightweight, detached portion of a DOM tree that can be manipulated separately before being inserted into a document.

How it is used
Supports efficient insertion of generated HTML into one or more locations in a document.
How deep it goes
Defines fragments as node containers and demonstrates adding, inserting, and cloning them.
Examples
Demonstrates building nodes from an HTML string and inserting a fragment into multiple document locations.
What you can do after
Apply it via document.createDocumentFragment() to batch node insertion and clone content for additional targets.

Read how Secrets of the JavaScript Ninja, Second Edition explains DOM fragment →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.