Example 1 — Count with embeds.length
Count every <embed> on the page.
const count = document.embeds.length;
console.log("embed count:", count);
if (count === 0) {
console.log("No <embed> elements on this page");
} How It Works
- Read
document.embeds. LiveHTMLCollectionof embeds (MDN). - Use
.length. Number of<embed>tags only. - Iframes / objects do not count. Query those tags separately.
- Guard empty pages. Check
count === 0before indexing.

