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
Fundamentals
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.
Concept
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 header — Sec-CH-Device-Memory Client Hint (HTTP side).
Foundation
📝 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
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Read GiB estimate
navigator.deviceMemory
Detect API
"deviceMemory" in navigator
Is a number?
typeof navigator.deviceMemory === "number"
Low-memory branch
if (navigator.deviceMemory < 4) { … }
Secure page?
window.isSecureContext
Status (MDN)
Limited / not Baseline
Snapshot
🔍 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
Compare
📋 deviceMemory vs connection
navigator.deviceMemory
navigator.connection
Answers
How much RAM (approx)?
How fast / metered is the network?
Unit
GiB number
effectiveType, downlink, rtt
Best for
Heavy UI / JS budget
Media quality / prefetch
Support
Limited / not Baseline
Limited / experimental family
Use together?
Yes — low RAM and slow network both suggest lighter experiences
Hands-On
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.
isSecureContext: true
deviceMemory: present
(on supporting secure pages)
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.`);
}
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.
LimitedNot Baseline
Google ChromeDevice Memory API supported (secure context)
Supported
Microsoft EdgeChromium Edge — follows Chrome Device Memory support
Supported
OperaChromium-based — Device Memory generally available
Supported
Mozilla FirefoxNot available for typical web content
Unavailable
Apple SafariNot available (desktop / iOS)
Unavailable
deviceMemoryLimited
Bottom line: Detect deviceMemory over HTTPS, adapt when present, and never rely on it as a unique fingerprint.
Wrap Up
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.
Assume desktop Chrome equals mobile Chrome buckets
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about deviceMemory
Approximate GiB hint — privacy-coarsened and optional.
5
Core concepts
💻01
Returns
GiB number
Approx
🔒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.