Navigator: deviceMemory property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The deviceMemory read-only property of the Navigator interface returns the approximate amount of device memory in gigabytes.
The reported value is imprecise to curtail fingerprinting. It's approximated by rounding the actual memory to the nearest power of 2, then dividing that number by 1024. It is then clamped within lower and upper bounds to protect the privacy of owners of very low-memory or high-memory devices. These bounds may change over time (see browser compatibility table).
Value
A floating point number coarsened to a power of two value, clamped to implement-defined limits.
For example, if a browser does not report below 2 or above 32 then the value is one of: 2, 4, 8, 16, 32.
Examples
const memory = navigator.deviceMemory;
console.log(`This device approximately ${memory}GiB of RAM.`);
Specifications
| Specification |
|---|
| Device Memory API> # sec-device-memory-js-api> |
Browser compatibility
See also
Sec-CH-Device-MemoryHTTP header