JavaScript Document applets Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.applets is a read-only property that returns an HTMLCollection. In older browsers it listed Java <applet> elements; today it is always empty (MDN).

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

Syntax

Use document.applets. Start with this line.

JavaScript
document.applets
CallWhat it does
document.appletsPrimary signature.

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

Library declarations
JavaScript
document.applets

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Empty HTMLCollection

JavaScript Examples

Example 1 — length Is Always Zero

Confirm the collection is empty on today’s browsers.

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

How It Works

  1. Read the property. document.applets returns an HTMLCollection.
  2. Check .length. Modern engines report 0.
  3. Compare to zero. Useful when auditing old “has applet?” scripts.
  4. MDN fact. The collection stays empty because <applet> support is gone.

Example 2 — Indexed Access Is Empty

There is no first applet element to read.

JavaScript
console.log(document.applets[0]);               // undefined
console.log(typeof document.applets[0]);        // "undefined"
Try It Yourself

How It Works

  1. Index into the collection. Empty collections have no item at [0].
  2. Get undefined. Same idea as reading past the end of an array.
  3. Do not call methods on it. document.applets[0].anything would throw.
  4. Guard first. Always check length before using an index (legacy habit).

Example 3 — Safe Legacy Guard (Then Migrate)

Pattern you may see in old code — rewrite it away after you understand it.

JavaScript
if (document.applets.length > 0) {
  console.log("Legacy applets present — unexpected today");
} else {
  console.log("No applets (expected on modern browsers)");
}
Try It Yourself

How It Works

  1. Branch on length. Old sites used this to detect embedded Java.
  2. Else path always wins today. Modern browsers hit the empty case.
  3. Migration tip. Delete the branch that assumes applets can run.
  4. Replace the feature. Rebuild the interaction with current web APIs.

Browser Support

Document.applets is Deprecated (MDN). Engines may still expose the property, but it returns an empty HTMLCollection because <applet> support was removed.

✓ Deprecated · Always empty

Document.applets

Legacy empty HTMLCollection — kept only for compatibility with old scripts.

Legacy Avoid in new apps
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
applets Deprecated

Bottom line: Safe to read without throwing, but useless for features. Remove applet detection and rebuild interactive content with modern web APIs.

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.
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 needed a browser plugin and were replaced by modern web technologies such as Canvas, WebGL, and WebAssembly.
No direct replacement — applets themselves are obsolete. Build interactive content with standard web APIs 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.

Next: bgColor

Learn the legacy Document background-color property.

bgColor 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