JavaScript Document embeds Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

document.embeds is a read-only property that returns a live HTMLCollection of every <embed> element in the document (MDN).

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

Syntax

Use document.embeds. Start with this line.

JavaScript
document.embeds
CallWhat it does
document.embedsPrimary signature.

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

Library declarations
JavaScript
document.embeds

Parameters

ParameterDescription
Writable?Optional. Read-only

Return Value

Return ValueDescription
*Live HTMLCollection

JavaScript Examples

Example 1 — Count with embeds.length

Count every <embed> on the page.

JavaScript
const count = document.embeds.length;
console.log("embed count:", count);

if (count === 0) {
  console.log("No <embed> elements on this page");
}
Try It Yourself

How It Works

  1. Read document.embeds. Live HTMLCollection of embeds (MDN).
  2. Use .length. Number of <embed> tags only.
  3. Iframes / objects do not count. Query those tags separately.
  4. Guard empty pages. Check count === 0 before indexing.

Example 2 — Loop and Read Each src

Inspect every embed’s resource URL.

JavaScript
for (const el of document.embeds) {
  console.log(el.tagName, el.src || "(no src)");
}
Try It Yourself

How It Works

  1. Iterate the collection. Each item is an HTMLEmbedElement.
  2. Read src. Resource URL for that embed.
  3. Fallback text. Use || "(no src)" when the attribute is missing.
  4. Index loops work too. document.embeds[i] is fine everywhere.

Example 3 — Live Updates and plugins Alias

Prove the collection grows when you append an embed, and matches plugins.

JavaScript
const before = document.embeds.length;

const el = document.createElement("embed");
el.src = "https://example.com/demo.pdf";
el.type = "application/pdf";
document.body.appendChild(el);

console.log(before, "→", document.embeds.length);
console.log("same as plugins?", document.embeds === document.plugins);
Try It Yourself

How It Works

  1. Store length before the change.
  2. Create and append an embed. DOM update is enough.
  3. Read length again. Live collection increases by one.
  4. Compare to plugins. Same object in modern HTML (MDN / HTML standard).

Browser Support

Document.embeds is marked Baseline Widely available on MDN (since June 2018). Logos use the shared browser-image-sprite.png sprite from this project.

✓ Baseline · Widely available

Document.embeds

Read-only live HTMLCollection of every <embed> element in the document.

Widely Available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Supported in legacy IE
Full support
Document.embeds Baseline support

Bottom line: Use document.embeds to list every embed on a page. It excludes iframe/object/video — and document.plugins points at the same collection. See the MDN Document.embeds reference.

Frequently Asked Questions

A read-only HTMLCollection of every <embed> element in the current document (MDN). Each item is an HTMLEmbedElement.
No. MDN marks Document.embeds as Baseline Widely available (since June 2018). It is a standard Document collection property.
No. The collection filters only <embed> elements. Use querySelectorAll("iframe") or "object" for those other tags.
Yes in modern HTML: document.plugins returns the same live HTMLCollection of embed elements as document.embeds.
Yes. If you add or remove an <embed>, document.embeds.length and indexed access update automatically.
Both work. document.embeds is a convenient live collection of all embeds. querySelectorAll("embed") returns a static NodeList and supports richer CSS filters.

Next: Document featurePolicy

Inspect Permissions Policy with the FeaturePolicy API.

featurePolicy 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