JavaScript Document applets Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Instance property

What You’ll Learn

Document.applets is a read-only deprecated instance property that once listed Java <applet> elements on a page. Today it always returns an empty HTMLCollection. Learn why applets disappeared, what legacy code looked like, and how to clean up obsolete detection scripts—with five examples and try-it labs.

01

Kind

Read-only property

02

Returns

HTMLCollection

03

Status

Deprecated

04

Length

Always 0 today

05

Element

<applet> removed

06

Today

Compatibility only

Introduction

In the late 1990s and early 2000s, some websites embedded Java programs using the HTML <applet> tag. Scripts could enumerate them with document.applets, similar to how document.anchors listed named anchors.

That era is over. MDN notes that support for the <applet> element has been removed by all browsers, so document.applets always returns an empty collection now.

💡
Learn it for history, not for shipping

Study document.applets to understand legacy intranet pages and old tutorials—then remove or rewrite any applet-related code you still find. See MDN Document: applets.

Related Document tutorials: anchors, all, Document constructor.

Understanding Document.applets

A read-only instance property on Document. Its value is an HTMLCollection. In historical browsers it listed every <applet> element; in modern engines the collection is always empty.

  • ValueHTMLCollection (empty in all current browsers).
  • Read-only — you do not assign a new collection to document.applets.
  • Legacy purpose — enumerate embedded Java applets on a page.
  • Modern realitylength is 0; no applets run.
  • Indexed accessdocument.applets[i] is always undefined today.

📝 Syntax

JavaScript
document.applets

Value

An empty HTMLCollection in modern browsers (MDN).

Typical modern check

JavaScript
console.log(document.applets.length); // 0 — always empty today

⚡ Quick Reference

GoalCode / note
Legacy propertydocument.applets
Count (modern)document.applets.length === 0
Collection typeHTMLCollection
First item (modern)undefined
HTML element<applet> — removed from browsers
MDN statusDeprecated

🔍 At a Glance

Four facts about document.applets.

Type
HTMLCollection

Read-only

Contents
always empty

Modern browsers

Status
deprecated

Legacy API

Use instead
web standards

Canvas / WASM

📋 Then vs Now

Eradocument.appletsWhat developers did
1990s–2000sListed live <applet> nodesEmbedded Java via browser plugins
2010sDeclining supportMigrated to Flash, Canvas, or native apps
TodayAlways empty collectionRemove applet markup and detection code
Modern webNo replacement propertyCanvas, WebGL, WebAssembly, video

Examples Gallery

Examples follow MDN Document: applets. Use View Output or Try It Yourself for each case.

📚 Getting Started

Confirm the property exists but returns nothing today.

Example 1 — Read document.applets.length

MDN: the collection is always empty in modern browsers.

JavaScript
console.log(document.applets.length);
console.log(document.applets.length === 0); // true today
Try It Yourself

How It Works

Even if old HTML still contains <applet> tags, browsers no longer instantiate them, so the collection stays empty.

Example 2 — Inspect the Collection Type

The property still returns an HTMLCollection object for compatibility.

JavaScript
console.log(document.applets.constructor.name);
console.log(typeof document.applets.length); // "number"
console.log(document.applets.item(0));       // null
Try It Yourself

How It Works

The API surface remains so old scripts do not throw when they access document.applets.

📈 Legacy Patterns & Cleanup

What old code did and how to modernize it.

Example 3 — Loop Over an Empty Collection

Historical scripts iterated applets; today the loop body never runs.

JavaScript
let count = 0;
for (const applet of document.applets) {
  count++;
  console.log(applet); // never reached today
}
console.log("applets found:", count);
Try It Yourself

How It Works

Safe to delete entire applet-enumeration blocks during legacy cleanup—they no longer affect behavior.

Example 4 — Compare with querySelectorAll("applet")

DOM queries for removed elements also return nothing useful.

JavaScript
const queried = document.querySelectorAll("applet");
console.log("querySelectorAll:", queried.length);
console.log("document.applets:", document.applets.length);
console.log("both empty:", queried.length === 0 && document.applets.length === 0);
Try It Yourself

How It Works

There is no modern selector-based workaround because the underlying feature is gone—not just deprecated.

Example 5 — Remove Legacy Applet Detection

Replace obsolete guards with straightforward modern logic.

JavaScript
// Legacy (remove):
// if (document.applets.length > 0) {
//   initJavaAppletBridge();
// }

// Modern: applets are unsupported — skip or show a message
function initInteractiveContent() {
  console.log("Using Canvas / WASM instead of applets");
}
initInteractiveContent();
Try It Yourself

How It Works

When auditing old codebases, treat any document.applets branch as dead code you can delete.

🚀 Common Use Cases

  • Reading legacy intranet pages — recognize applet enumeration scripts.
  • Code archaeology — understand pre-HTML5 interactive content patterns.
  • Migration audits — find and remove dead document.applets checks.
  • Teaching web history — contrast plugins with open web standards.
  • Not for new apps — never embed or query Java applets.
  • Security reviews — flag remaining <applet> markup for removal.

🧠 How document.applets Fit the Web Platform

1

Page embeds <applet>

Java plugin ran bytecode inside the browser.

Legacy
2

Script reads document.applets

Returned an HTMLCollection of applet elements.

DOM
3

Browsers remove plugin support

<applet> is obsolete; NPAPI/Java plugins gone.

Removed
4

Empty collection forever

Property kept for compatibility; always returns length 0 today.

📝 Notes

  • document.applets is deprecated (MDN) — avoid in new code.
  • Read-only property; returns an HTMLCollection, not a plain array.
  • MDN: support for <applet> removed; collection always empty.
  • No modern DOM replacement—the feature itself is obsolete.
  • Do not confuse with document.embeds or document.plugins (also legacy).
  • Related: anchors, ownerDocument, all.

Legacy Browser Support

Document.applets is deprecated and returns an empty collection in all modern browsers because the <applet> element is no longer supported. Logos use the shared browser-image-sprite.png sprite from this project.

Deprecated · Removed feature

Document.applets

Legacy HTMLCollection for Java applets — always empty today; applet element removed.

Removed Compatibility shell only
Google Chrome Applet removed · empty collection
Deprecated
Mozilla Firefox Applet removed · empty collection
Deprecated
Apple Safari Applet removed · empty collection
Deprecated
Microsoft Edge Applet removed · empty collection
Deprecated
Opera Follow Chromium behavior
Deprecated
Internet Explorer Historical applet support (EOL)
Legacy only
Document.applets Always empty

Bottom line: document.applets exists so old scripts do not crash. Do not embed applets or depend on this property — use modern web APIs for interactive content.

Conclusion

Document.applets is a deprecated read-only property from the Java-applet era. Modern browsers keep it as an empty HTMLCollection so legacy scripts do not break. Learn it to read old code and remove obsolete applet logic—not to build new features.

Continue with bgColor, ownerDocument, anchors, Document constructor, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Remove <applet> markup from maintained pages
  • Delete dead document.applets.length checks during refactors
  • Use Canvas, WebGL, or WebAssembly for interactive content
  • Document legacy behavior when auditing old enterprise sites
  • Prefer open web standards over browser plugins

❌ Don’t

  • Embed Java applets in new projects
  • Expect document.applets to list anything today
  • Keep plugin-detection code that can never succeed
  • Confuse applets with <embed> or <object> without reviewing specs
  • Assume a future browser will restore applet support

Key Takeaways

Knowledge Unlocked

Five things to remember about document.applets

Deprecated empty collection — Java applets are gone.

5
Core concepts
⚠️02

Status

deprecated

Legacy
🔢03

Length

always 0

MDN
04

Element

<applet>

Removed
🛠05

Action

remove legacy code

Migrate

❓ Frequently Asked Questions

A read-only HTMLCollection that is always empty in modern browsers. It exists only for backwards compatibility with very old pages that embedded Java applets.
Yes. MDN marks Document.applets as deprecated. Support for the HTML applet element has been removed from all major browsers, so the property no longer lists any elements.
Browsers no longer support the obsolete <applet> element. MDN states that calling document.applets always returns an empty collection today.
Applets were small Java programs embedded in web pages via <applet>. They required a browser plugin and were replaced by modern web APIs such as Canvas, WebGL, and WebAssembly.
No direct replacement exists because applets themselves are obsolete. Build interactive content with standard web technologies instead of querying for applet elements.
No. Do not embed applets or read document.applets in new code. Remove legacy applet-detection scripts when you maintain old pages.
Did you know?

Java applets once powered everything from online calculators to enterprise dashboards. When browsers dropped NPAPI and plugin support, the DOM kept document.applets as an empty shell so scripts written in 2003 would not throw a ReferenceError on property access.

Next: bgColor

Learn the deprecated background color property on Document.

bgColor →

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.

6 people found this page helpful