JavaScript Navigator deviceMemory Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.deviceMemory is a read-only property that returns the approximate amount of device memory (RAM) in gigabytes (MDN). Use it as a soft hint for lighter pages on low-memory devices.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.deviceMemory. Start with this line.

JavaScript
navigator.deviceMemory
CallWhat it does
navigator.deviceMemoryPrimary signature.

Built into the browser. Read navigator.deviceMemory on Navigator — no import required.

Library declarations
JavaScript
navigator.deviceMemory

Parameters

ParameterDescription
deviceMemoryOptional. Approximate RAM in GiB
Feature detectRequired. Avoid errors on unsupported browsers

Return Value

Return ValueDescription
*Number — approximate GiB

JavaScript Examples

Example 1 — Feature-Detect

Check whether deviceMemory exists before reading it.

JavaScript
const supported = "deviceMemory" in navigator;
console.log(supported ? "deviceMemory available" : "deviceMemory missing");
Try It Yourself

How It Works

  1. Use in. "deviceMemory" in navigator is true only when the property exists.
  2. Branch on support. Chromium often has it; Firefox and Safari usually do not.
  3. Log a clear message. Students can see support without throwing.
  4. Never assume Baseline. Always keep a fallback path.

Example 2 — Read Approximate GiB

MDN-style read: print the approximate RAM message when supported.

JavaScript
if (!("deviceMemory" in navigator)) {
  console.log("unsupported");
} else {
  const memory = navigator.deviceMemory;
  console.log(`This device approximately ${memory}GiB of RAM.`);
}
Try It Yourself

How It Works

  1. Detect first. Exit early when the property is missing.
  2. Read once. Store navigator.deviceMemory in memory.
  3. Expect buckets. Values look like powers of two, not exact OS RAM.
  4. Use as a hint. Great for logging or adaptive loading — not fingerprinting.

Example 3 — Adaptive Experience Tier

Pick a lighter experience when reported memory is low; default to full when unsupported.

JavaScript
function pickExperienceTier() {
  const mem = navigator.deviceMemory;
  if (typeof mem !== "number") return "full"; // safe default
  if (mem < 2) return "minimal";
  if (mem < 4) return "light";
  return "full";
}

console.log("tier: " + pickExperienceTier());
Try It Yourself

How It Works

  1. Read the value. mem may be a number or undefined.
  2. Default to full. Unsupported browsers are not punished.
  3. Map coarse tiers. Under 2 → minimal; under 4 → light; else full.
  4. Act on the tier. Skip heavy widgets only on lower tiers.

Browser Support

Navigator.deviceMemory (Device Memory API) is Limited availability (not Baseline) on MDN. It requires a secure context. It is not Deprecated, Experimental, or Non-standard.

✓ Limited · Not Baseline

Navigator.deviceMemory

Supported in Chrome 63+, Edge 79+, Opera 50+, and Samsung Internet 8.2+. Not available in Firefox or Safari. Always feature-detect.

Limited Not Baseline
Google Chrome 63+ · Secure context
Supported
Microsoft Edge 79+ · Chromium
Supported
Opera 50+ · Chromium-based
Supported
Mozilla Firefox Not available for typical web content
Unavailable
Apple Safari Not available (desktop / iOS)
Unavailable
Samsung Internet 8.2+ · Android
Supported
navigator.deviceMemory Limited

Bottom line: Detect over HTTPS, adapt when present, default to a full experience when missing, and never use the value as a fingerprint.

Frequently Asked Questions

It is a read-only Navigator property that returns the approximate amount of device memory (RAM) in gigabytes (GiB). The value is coarsened for privacy (MDN).
MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context. Always feature-detect.
Yes. MDN: available only in secure contexts (HTTPS or localhost) in supporting browsers.
MDN: RAM is rounded to the nearest power of 2, divided by 1024, then clamped to lower/upper bounds to reduce fingerprinting. Example buckets may look like 2, 4, 8, 16, or 32.
Treat it as a capability hint for adaptive loading. On low reported memory, reduce heavy features; when unsupported, keep a solid default. Do not use it as a unique device fingerprint.
No. The property is read-only. You read the approximate GiB number when it exists.

Next: devicePosture

Learn the Device Posture API for foldable continuous vs folded layouts.

devicePosture 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