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
Client Hints extension
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Device-Memory | Chrome Full support 61 | Edge Full support ≤79 | Firefox ? | IE ? | Opera Full support 48 | Safari ? | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox 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.