JavaScript Document implementation Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.implementation is a read-only property that returns a DOMImplementation object (MDN)—a factory for creating documents and document types that are not tied to the live page tree.

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.implementation. Start with this line.

JavaScript
document.implementation
CallWhat it does
document.implementationPrimary signature.

Built into the browser. Read or assign document.implementation — no import required.

Library declarations
JavaScript
document.implementation

Parameters

ParameterDescription
implementationRequired. Read-only accessor to the factory
Factory methodRequired. createHTMLDocument, createDocumentType, ...
Import / displayOptional. Needed only to show sandbox nodes on the live page

Return Value

Return ValueDescription
*The current value of document.implementation.

JavaScript Examples

Example 1 — Read document.implementation

Confirm the property returns a DOMImplementation factory object.

JavaScript
const impl = document.implementation;

console.log(Object.prototype.toString.call(impl));
console.log(typeof impl.createHTMLDocument);
Try It Yourself

How It Works

  1. Read the property. No arguments—just access document.implementation.
  2. Check the type tag. toString reports [object DOMImplementation].
  3. Confirm a method. createHTMLDocument is a function on that object.
  4. Next step. Call a factory method when you need a new document.

Example 2 — createHTMLDocument(title)

Build a blank HTML document in memory without navigating the browser.

JavaScript
const newDoc = document.implementation.createHTMLDocument("My Sandbox");

console.log(newDoc.title);
console.log(newDoc.body.tagName);
Try It Yourself

How It Works

  1. Call the factory. Pass an optional title string for the new document.
  2. Get a full HTML skeleton. The new doc already has head and body.
  3. Read title. newDoc.title is "My Sandbox".
  4. Isolated tree. Changes here do not affect the visible page until you import or display them.

Example 3 — Add Content to a Sandbox Document

Create elements on the new document and append them to its body.

JavaScript
const sandbox = document.implementation.createHTMLDocument("Preview");

const p = sandbox.createElement("p");
p.textContent = "Hello from a new Document!";
sandbox.body.appendChild(p);

console.log(sandbox.body.textContent);
Try It Yourself

How It Works

  1. Create the sandbox. createHTMLDocument returns a separate Document.
  2. Use the sandbox API. Call sandbox.createElement so the node belongs to that document.
  3. Append to sandbox body. The live page’s document.body is unchanged.
  4. Read the result. textContent shows the paragraph text from the in-memory document.

Browser Support

Document.implementation is Baseline Widely available on MDN (since July 2015). It works across modern browsers and long-supported evergreen releases.

✓ Baseline · Widely available

Document.implementation

Read-only access to DOMImplementation — factory methods for creating documents and document types.

99% Browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
implementation Excellent

Bottom line: Safe everywhere you teach DOM APIs. Prefer createHTMLDocument for sandboxes. Never rely on deprecated hasFeature() for feature detection.

Frequently Asked Questions

A DOMImplementation object associated with the current document (MDN). It provides document-independent factory methods such as createHTMLDocument and createDocumentType.
No. MDN marks Document.implementation as Baseline Widely available (since July 2015). The property itself is standard and widely supported.
No. DOMImplementation.hasFeature() is deprecated. Modern browsers always return true, so it is useless for real feature detection. Prefer checks like "fullscreenEnabled" in document.
It creates a new in-memory HTML Document with head and body already present — useful for sandboxes, templates, and tests without loading a URL.
document.doctype reads this page's DocumentType node (or null). document.implementation is a factory that can create new documents and DocumentType nodes.
No. It is a read-only accessor. You call methods on the returned DOMImplementation object; you do not replace the property.

Next: lastElementChild

Learn how to read the last element child on a document or element node.

lastElementChild tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful