Device Memory API

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

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Capabilities of the client devices largely depend on the amount of available RAM. Traditionally, developrs had to use heruistics and either benchmark the device or infer the device capabilities based on other factors like device manufacturer or User Agent strings.

Accessing device memory capacity

There are two ways to acces the approximate amount of RAM device has: via JavaScript API and via Client Hints HTTP header.

JavaScript API

You may query the approximate amount of ram device has by retreiving Navigator.deviceMemory

var ram1 = window.navigator.deviceMemory;
var ram2 = navigator.deviceMemory;

Both of these will return the same result.

Client Hints Header

You also may use Client Hints directive Device-Memory to retreive the same approximate RAM capacity.

Specifications

Specification Status Comment
Device Memory 1 Editor's Draft Initial definition.

Browser compatibility

JavaScript interface

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
deviceMemory
Experimental
Chrome Full support 63Edge Full support ≤79Firefox ? IE ? Opera Full support 50Safari ? WebView Android Full support 63Chrome Android Full support 63Firefox Android ? Opera Android Full support 46Safari iOS ? Samsung Internet Android Full support 8.0

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

Client Hints extension

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Device-Memory
Experimental
Chrome Full support 61Edge Full support ≤79Firefox ? IE ? Opera Full support 48Safari ? WebView Android Full support 61Chrome Android Full support 61Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android Full support 8.0

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also