大网数据广告活动
Web 标准与前端开发

`prefers-reduced-data` CSS media feature

· 52CE 我爱测

> [!WARNING] > This feature is not supported by any user agent and its specifics are subject to change.

[!WARNING] This feature is not supported by any user agent and its specifics are subject to change.

The prefers-reduced-data CSS media feature is used to detect if the user has requested web content that consumes less internet traffic.

The browser typically achieves this by querying the underlying operating system's preferences for reduced data.

Syntax

  • no-preference
    • : Indicates that the user has made no preference known to the system. This keyword evaluates to false in the Boolean context.
  • reduce
    • : Indicates that the user has expressed a preference for lightweight alternate content.

Examples

Basic usage

In this example, the montserrat-regular.woff2 font file will neither be preloaded nor downloaded if the user prefers reduced data; in this case, the "system font stack" will serve as the fallback font:

HTML

<head>
  <link
    rel="preload"
    href="fonts/montserrat-regular.woff2"
    as="font"
    media="(prefers-reduced-data: no-preference)"
    crossorigin />
  <link rel="stylesheet" href="style.css" />
</head>

CSS

@media (prefers-reduced-data: no-preference) {
  @font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    /* latin */
    src:
      local("Montserrat Regular"),
      local("Montserrat-Regular"),
      url("fonts/montserrat-regular.woff2") format("woff2");
    unicode-range:
      U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
      U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
      U+FEFF, U+FFFD;
  }
}

body {
  font-family:
    "Montserrat",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Roboto",
    "Helvetica",
    "Arial",
    sans-serif;
}

Specifications

Browser compatibility

See also

  • Save-Data HTTP header

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。