Device Memory API

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

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 HTTP Header with the Device-Memory directive to retrieve the same approximate RAM capacity.

Interfaces

Extensions to other interfaces

Returns the approximate amount of device memory in gigabytes.

WorkerNavigator.deviceMemory Read only

Returns the approximate amount of device memory in gigabytes.

Specifications

Specification
Device Memory

Browser compatibility

api.Navigator.deviceMemory

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
deviceMemory

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

api.WorkerNavigator.deviceMemory

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
deviceMemory

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

http.headers.Device-Memory

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Device-Memory request header

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also