Device Memory API

W3C Working Draft,

More details about this document
This version:
https://www.w3.org/TR/2026/WD-device-memory-1-20260327/
Latest published version:
https://www.w3.org/TR/device-memory/
Editor's Draft:
https://www.w3.org/TR/device-memory/
Previous Versions:
History:
https://www.w3.org/standards/history/device-memory-1/
Feedback:
GitHub
Editors:
(Google)
(Microsoft)
Former Editor:
Shubhie Panicker (Google)

Abstract

This document defines a HTTP Client Hint header and a JavaScript API to surface device capability for memory (device RAM) in order to enable web apps to customize content depending on device memory constraints.

Status of this document

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index.

This document was published by the Web Performance Working Group as a Working Draft using the Recommendation track. Publication as a Working Draft does not imply endorsement by W3C and its Members.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress.

GitHub Issues are preferred for discussion of this specification.

This document is governed by the 18 August 2025 W3C Process Document.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

1. Introduction

A device-class signal is used for several reasons, including:

Device identification and classification based on advertised User-Agent, and other characteristics of the client, are commonly used to select and provide optimized content. Such solutions frequently rely on commercial device databases, which are costly, hard to integrate, and hard to maintain.

This specification defines a (Client Hint) Header Field and a JavaScript API which exposes the approximate device memory (RAM) to address these needs without needing to use a device database.

2. Computing device memory value

The user agent’s deviceMemory is calculated by these steps:
  1. Let physicalDeviceMemory be the amount of physical memory in bytes.

  2. Let minimumLowerBound be an implementation-defined minimum bound.

  3. Let maximumUpperBound be an implementation-defined maximum bound.

  4. Let deviceMemory be physicalDeviceMemory / 1024.0.

  5. Let power be 0.

  6. While deviceMemory is greater than 1:

    1. Bitwise shift deviceMemory right 1 place.

    2. Increment power by 1.

  7. Let lowerBound be 2 to the power of power.

  8. Let upperBound be 2 to the power of |power + 1|.

  9. If physicalDeviceMemorylowerBoundupperBoundphysicalDeviceMemory, then deviceMemory’s value is lowerBound.

  10. Otherwise deviceMemory’s value is upperBound.

  11. If deviceMemory < minimumLowerBound, then deviceMemory is minimumLowerBound.

  12. If deviceMemory > maximumUpperBound, then deviceMemory is maximumUpperBound.

  13. Return deviceMemory.

The algorithm includes the ability for implementation-defined upper bound and a lower bounds. The range between the upper and the lower bounds should include the majority of device memory values but exclude rare device memory values to mitigate device fingerprinting. Implementations may adjust these bounds over time. These bounds may differ on different device types.

3. Sec-CH-Device-Memory (Client Hint) Header Field

The Sec-CH-Device-Memory header field is a HTTP Client Hint header. It is a structured header value containing an item which value is a decimal that indicates the client’s approximate amount of device memory (RAM) in GiB.

If `Sec-CH-Device-Memory` header field occurs in a message more than once, the last value overrides all previous occurrences.

The ABNF (Augmented Backus-Naur Form) syntax for the `Sec-CH-Device-Memory` header field is as follows:

Sec-CH-Device-Memory = sf-decimal

The `Sec-CH-Device-Memory`'s value should be set to the user agent’s deviceMemory.

3.1. Client Hint examples

A server opts in to receive a `Sec-CH-Device-Memory` HTTP Client Hint using the Accept-CH header field, or an equivalent HTML meta element with http-equiv attribute:
Accept-CH: Sec-CH-Device-Memory

In turn, on receiving the above preferences from the server, a compatible user agent would then advertise the device capability for memory, via the `Sec-CH-Device-Memory` request header field:

GET /example HTTP/1.1
Sec-CH-Device-Memory: 8
...

4. Device Memory JavaScript API

[
    SecureContext,
    Exposed=(Window,Worker)
] interface mixin NavigatorDeviceMemory {
    readonly attribute double deviceMemory;
};

Navigator includes NavigatorDeviceMemory;
WorkerNavigator includes NavigatorDeviceMemory;

The NavigatorDeviceMemory’s deviceMemory getter steps are to return the user agent’s deviceMemory.

4.1. JavaScript examples

A web application can either enable or disable features based on device memory.

Note: The web application should consider how to handle browsers that do not support the API: either by enabling by default, or disabling by default.

const mem = navigator.deviceMemory;

// Either disable features if it is known to be a low-memory device
if (mem && mem < 2) {
    // disable features to provide a better experience
}

// Or, alternatively only enable features if the device memory is
// either not provided, or known to be above minimum requirements
if (!mem || mem > 4) {
    // enable features to provide a better experience
}
A RUM solution can query the device memory using navigator.deviceMemory API and include this in performance beacons as additional information to help explain or segment the data.
const mem = navigator.deviceMemory;
const analyticsData = {
    memory: mem;
    ... other metrics
}
navigator.sendBeacon("/endpoint", analyticsData);

5. Security & privacy considerations

`Sec-CH-Device-Memory` Client Hint header and JavaScript API will only be available to HTTPS secure contexts.

To reduce fingerprinting risk, the reported value is rounded to a single significant bit, as opposed to reporting the exact value. In addition, an implementation-specific upper and lower bound is placed on the reported values. These bounds should be reviewed over time as commonly used device memory characteristics change. Device type should be taken into account when defining these bounds since mobile devices typically have different characteristics than desktops and laptops.

6. IANA considerations

This document defines the `Sec-CH-Device-Memory` HTTP request header field, and registers them in the permanent message header field registry ([RFC3864]).

6.1. Sec-CH-Device-Memory header field

Header field name

Sec-CH-Device-Memory

Applicable protocol

http

Status

standard

Author/Change controller

IETF

Specification document

This specification (§ 3 Sec-CH-Device-Memory (Client Hint) Header Field)

7. Acknowledgements

Special thanks to the previous editor Shubhie Panicker and all the contributors for their technical input and suggestions that led to improvements to this specification.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Conformant Algorithms

Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.

Conformance requirements phrased as algorithms or specific steps can be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to understand and are not intended to be performant. Implementers are encouraged to optimize.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119
[RFC8941]
M. Nottingham; P-H. Kamp. Structured Field Values for HTTP. February 2021. Proposed Standard. URL: https://httpwg.org/specs/rfc8941.html
[RFC8942]
I. Grigorik; Y. Weiss. HTTP Client Hints. February 2021. Experimental. URL: https://www.rfc-editor.org/rfc/rfc8942

Informative References

[RFC3864]
G. Klyne; M. Nottingham; J. Mogul. Registration Procedures for Message Header Fields. September 2004. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc3864