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
Call
What it does
navigator.deviceMemory
Primary signature.
Built into the browser. Read navigator.deviceMemory on Navigator — no import required.
Library declarations
JavaScript
navigator.deviceMemory
Parameters
Parameter
Description
deviceMemory
Optional. Approximate RAM in GiB
Feature detect
Required. Avoid errors on unsupported browsers
Return Value
Return Value
Description
*
Number — approximate GiB
JavaScript Examples
Example 1 — Feature-Detect
Check whether deviceMemory exists before reading it.
deviceMemory available
/* or: deviceMemory missing */
How It Works
Use in."deviceMemory" in navigator is true only when the property exists.
Branch on support. Chromium often has it; Firefox and Safari usually do not.
Log a clear message. Students can see support without throwing.
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.`);
}
tier: full
/* or: light / minimal on lower reported GiB */
How It Works
Read the value.mem may be a number or undefined.
Default to full. Unsupported browsers are not punished.
Map coarse tiers. Under 2 → minimal; under 4 → light; else full.
Act on the tier. Skip heavy widgets only on lower tiers.
Compatibility
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.
LimitedNot Baseline
Google Chrome63+ · Secure context
Supported
Microsoft Edge79+ · Chromium
Supported
Opera50+ · Chromium-based
Supported
Mozilla FirefoxNot available for typical web content
Unavailable
Apple SafariNot available (desktop / iOS)
Unavailable
Samsung Internet8.2+ · Android
Supported
navigator.deviceMemoryLimited
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.