JavaScript Navigator deviceMemory Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Limited support

What You’ll Learn

navigator.deviceMemory returns the approximate device RAM in GiB from the Device Memory API. Learn privacy coarsening, secure context rules, adaptive loading, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

Number (GiB)

03

Baseline

Not Baseline

04

Context

Secure (HTTPS)

05

Precision

Coarsened

06

Use

Adaptive loading

Introduction

Low-memory phones struggle with heavy pages: big images, complex animations, and large JavaScript bundles. The Device Memory API exposes a rough RAM estimate so you can dial features down when needed.

navigator.deviceMemory is read-only and returns an approximate amount of memory in gigabytes. MDN stresses the value is intentionally imprecise to reduce fingerprinting.

💡
Hint, not a fingerprint

Use it to improve UX on constrained devices. Do not treat the number as a unique device ID. Always keep a good default when the property is missing.

Understanding the deviceMemory Property

Think of deviceMemory as a coarse “how much RAM?” bucket — not the exact megabyte count from your OS settings.

  • Approximate GiB — floating-point number coarsened to a power of two.
  • Clamped — browsers may hide very low or very high extremes for privacy.
  • Example buckets — MDN notes values like 2, 4, 8, 16, 32 when bounds apply.
  • Secure context — HTTPS / localhost in supporting browsers.
  • Related headerSec-CH-Device-Memory Client Hint (HTTP side).

📝 Syntax

General form of the property:

JavaScript
navigator.deviceMemory

Value

  • A floating-point number: approximate device memory in GiB (when supported).

Common patterns

JavaScript
// MDN-style log:
const memory = navigator.deviceMemory;
console.log(`This device approximately ${memory}GiB of RAM.`);

// Adaptive check (when present):
if (typeof navigator.deviceMemory === "number" && navigator.deviceMemory < 4) {
  // Prefer lighter assets / fewer heavy widgets
}

⚡ Quick Reference

GoalCode
Read GiB estimatenavigator.deviceMemory
Detect API"deviceMemory" in navigator
Is a number?typeof navigator.deviceMemory === "number"
Low-memory branchif (navigator.deviceMemory < 4) { … }
Secure page?window.isSecureContext
Status (MDN)Limited / not Baseline

🔍 At a Glance

Four facts to remember about navigator.deviceMemory.

Returns
number (GiB)

Approximate

Baseline
no

Limited support

HTTPS
required

Secure context

Privacy
coarsened

Power-of-two

📋 deviceMemory vs connection

navigator.deviceMemorynavigator.connection
AnswersHow much RAM (approx)?How fast / metered is the network?
UnitGiB numbereffectiveType, downlink, rtt
Best forHeavy UI / JS budgetMedia quality / prefetch
SupportLimited / not BaselineLimited / experimental family
Use together?Yes — low RAM and slow network both suggest lighter experiences

Examples Gallery

Examples follow MDN Device Memory / navigator.deviceMemory patterns. Prefer Try It Yourself on a supporting Chromium browser over HTTPS. Use View Output for expected messaging.

📚 Getting Started

Detect the API and confirm a secure context.

Example 1 — Feature Detection

Check whether deviceMemory exists on navigator.

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

How It Works

Support is strongest in Chromium-based browsers. Always branch when missing.

Example 2 — Secure Context Check

Pair detection with isSecureContext.

JavaScript
const lines = [
  "isSecureContext: " + window.isSecureContext,
  "deviceMemory: " + (("deviceMemory" in navigator) ? "present" : "absent")
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

Serve Device Memory features over HTTPS (or localhost during development).

📈 Practical Patterns

Read the GiB value, adapt quality, and wrap a safe helper.

Example 3 — MDN Read & Log

Print the approximate RAM message from MDN.

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

Expect power-of-two style buckets — not your exact OS RAM figure.

Example 4 — Adaptive Experience Tier

Pick a lighter experience when reported memory is low.

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

Default to full when unsupported so Safari/Firefox users are not punished.

Example 5 — Safe Status Helper

Return structured results for UI or analytics (without fingerprinting obsessively).

JavaScript
function deviceMemoryStatus() {
  if (!window.isSecureContext) {
    return { ok: false, reason: "insecure-context" };
  }
  if (!("deviceMemory" in navigator)) {
    return { ok: false, reason: "unsupported" };
  }
  const gib = navigator.deviceMemory;
  return {
    ok: true,
    gib: gib,
    lowMemory: typeof gib === "number" && gib < 4
  };
}

console.log(JSON.stringify(deviceMemoryStatus()));
Try It Yourself

How It Works

Use lowMemory to toggle heavy widgets — keep analytics coarse and privacy-aware.

🚀 Common Use Cases

  • Lighter pages on low RAM — skip autoplaying video, reduce particle effects.
  • Image / asset budgets — serve smaller galleries when memory is constrained.
  • Defer heavy JS — load charts or editors only on higher-memory tiers.
  • RUM segmentation — coarse memory buckets in performance reports (privacy-aware).
  • Progressive enhancement — improve Chromium experiences without requiring the API.

🧠 How navigator.deviceMemory Works

1

Secure page + detect

HTTPS / localhost and "deviceMemory" in navigator.

Detect
2

Browser coarsens RAM

Rounds to power-of-two GiB and clamps extremes.

Privacy
3

You read the number

Use it as a capability hint for UX decisions.

Hint
4

Adapt or keep default

Lighten features when low; otherwise ship the normal experience.

📝 Notes

  • Limited availability / not Baseline — mainly Chromium; often missing in Safari and Firefox.
  • Not Deprecated, Experimental, or Non-standard on MDN — no status banner on this page.
  • Secure context required (HTTPS / localhost).
  • Values are approximate and clamped — never treat them as exact RAM.
  • Related: devicePosture, connection, JavaScript hub.

Limited Browser Support

navigator.deviceMemory (Device Memory API) is not Baseline. Support is strongest in Chromium-based browsers. Safari and Firefox typically omit it. Always feature-detect and keep a default experience.

Limited · Not Baseline

Navigator.deviceMemory

Use approximate GiB as an optional hint for lighter pages on low-memory devices.

Limited Not Baseline
Google Chrome Device Memory API supported (secure context)
Supported
Microsoft Edge Chromium Edge — follows Chrome Device Memory support
Supported
Opera Chromium-based — Device Memory generally available
Supported
Mozilla Firefox Not available for typical web content
Unavailable
Apple Safari Not available (desktop / iOS)
Unavailable
deviceMemory Limited

Bottom line: Detect deviceMemory over HTTPS, adapt when present, and never rely on it as a unique fingerprint.

Conclusion

navigator.deviceMemory gives an approximate GiB RAM hint for adaptive loading. Feature-detect it, require HTTPS, treat values as coarse buckets, and keep a strong default when the API is missing.

Continue with devicePosture, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before reading
  • Default to a full experience when unsupported
  • Use coarse tiers (minimal / light / full)
  • Combine with network hints when useful
  • Serve over HTTPS

❌ Don’t

  • Treat the number as exact OS RAM
  • Use it as a unique device fingerprint
  • Block Safari/Firefox with a worse default
  • Require deviceMemory for core features
  • Assume desktop Chrome equals mobile Chrome buckets

Key Takeaways

Knowledge Unlocked

Five things to remember about deviceMemory

Approximate GiB hint — privacy-coarsened and optional.

5
Core concepts
🔒 02

Privacy

Coarsened

Buckets
🔒 03

HTTPS

secure context

Security
04

Use

Adaptive UX

Hint
🔬 05

Support

Not Baseline

Detect

❓ 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 does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability / not Baseline — missing in some major browsers (notably Safari and Firefox for typical use). Always feature-detect.
Yes. It is available only in secure contexts (HTTPS or localhost) in supporting browsers.
MDN: values are rounded to powers of two and clamped to lower/upper bounds to reduce fingerprinting. Example reported buckets may look like 2, 4, 8, 16, or 32 depending on the browser.
Treat it as a capability hint. On low memory, reduce heavy features; when unsupported or higher, keep a solid default experience. Do not use it as a unique device fingerprint.
No. The property is read-only. You read the approximate GiB number when it exists.
Did you know?

The same approximate memory value can also be sent as an HTTP Client Hint via Sec-CH-Device-Memory — useful when you want to adapt on the server before HTML ships.

Learn devicePosture Next

Device Posture API for foldable continuous vs folded layouts.

devicePosture →

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.

8 people found this page helpful