Device Memory API

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

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

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

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.

Specifications

Specification
Device Memory
# sec-device-memory-js-api
Device Memory
# iana-device-memory

Browser compatibility

api.Navigator.deviceMemory

BCD tables only load in the browser

http.headers.Device-Memory

BCD tables only load in the browser

See also