e01.org

Device Memory API

Device Memory API

Device Memory API

The capabilities of a client device largely depend on the amount of available RAM. Traditionally, developers had to use heuristics and either benchmark a device or infer device capabilities based on other factors like the device manufacturer or User Agent strings.

## Determining device memory

There are two ways to determine the approximate amount of RAM a device has: use the Device Memory JavaScript API or accept Client Hints.

### JavaScript API

You may query the approximate amount of RAM a device has by retrieving Navigator.deviceMemory or WorkerNavigator.deviceMemory.

```js
const RAM = navigator.deviceMemory;
```

### Client Hints

You may also use the [Client Hints](/docs/Web/HTTP/Guides/Client_hints) HTTP Header with the `Device-Memory` directive to retrieve the same approximate RAM capacity.

## Interfaces

### Extensions to other interfaces

- Navigator.deviceMemory
- : Returns the approximate amount of device memory in gigabytes.
- WorkerNavigator.deviceMemory
- : Returns the approximate amount of device memory in gigabytes.

## Specifications

## Browser compatibility

## See also

- Sec-CH-Device-Memory header

source: MDN Web Docs mirror · page

Cite this

"Device Memory API". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/Device_Memory_API

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy