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 3 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 →

Vanilla Web

A lightweight DOM container that holds a subtree of nodes without being part of the document tree itself.

How it is used
Buffers DOM nodes for a grouped insertion and holds template markup until it is cloned for use.
How deep it goes
Explains child transfer, template ownership, deep cloning, importing, and listener caveats without detailing browser internals.
Examples
Uses repeated table rows, cards, tooltips, and component markup as template candidates, alongside buffered multi-node insertion.
What you can do after
Build it from scratch with native DOM creation APIs, or clone template content before inserting reusable nodes.

Read how Vanilla Web 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 →

What to know first

Related concepts

Questions about DOM fragment

What is DOM fragment?

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

Which Manning books explain DOM fragment?

Web Components in Action, Vanilla Web and Secrets of the JavaScript Ninja, Second Edition.

What should I know before learning DOM fragment?

Manning books that teach DOM fragment usually introduce Document Object Model and DOM node first.

What kinds of DOM fragment are there?

Kinds of DOM fragment include shadow root.

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.