document.customElementRegistry is a read-only property that returns the CustomElementRegistry for this document, or null if none is set (MDN). On a normal page it is the same object as window.customElements.
Read the notes below before you get or set this property. Prefer feature detection when support is limited.
Syntax
Use document.customElementRegistry. Start with this line.
JavaScript
document.customElementRegistry
Call
What it does
document.customElementRegistry
Primary signature.
Built into the browser. Read or assign document.customElementRegistry — no import required.
Library declarations
JavaScript
document.customElementRegistry
Parameters
Parameter
Description
Writable?
Optional. Read-only property
Return Value
Return Value
Description
*
CustomElementRegistry or null
JavaScript Examples
Example 1 — Same as window.customElements (MDN)
On the main document, the registries match when the Document property exists.
JavaScript
if ("customElementRegistry" in document) {
console.log(
document.customElementRegistry === window.customElements
); // true on Window-associated docs (MDN)
} else {
console.log("document.customElementRegistry not supported");
}
Choose a registry — Document property or window.customElements.
Check truthiness — still may be null on some documents.
Safe for production when you need a registry without requiring the newer Document accessor.
Compatibility
Browser Support
Document.customElementRegistry is Limited availability on MDN (not Baseline). The related window.customElements / CustomElementRegistry APIs are much more widely available — prefer them with a fallback.
✓ Limited · Not Baseline
Document.customElementRegistry
Returns the document’s CustomElementRegistry or null. Feature-detect; fall back to window.customElements.
MDN: the CustomElementRegistry associated with this document, or null if one has not been set.
MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) — feature-detect before production use.
MDN: for Window-associated documents they are the same global registry. document.customElementRegistry can be null on some programmatically created documents.
MDN: documents created programmatically (for example via DOMImplementation.createHTMLDocument()) have a null custom element registry by default.
Yes. MDN: the same customElementRegistry property is also available on ShadowRoot (useful for scoped registries).
Yes. Defining elements with customElements.define() is the everyday API. Use document.customElementRegistry when you need the document's registry object or null/scoped cases.