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

DeferredRequestInit

· 52CE 我爱测

The **`DeferredRequestInit`** dictionary of the Fetch API represents the set of options that can be used to configure a deferred fetch request.

Fetch API

The DeferredRequestInit dictionary of the Fetch API represents the set of options that can be used to configure a deferred fetch request.

The DeferredRequestInit object is passed directly into the window.fetchLater() function call as the second argument.

Instance properties

This dictionary extends the RequestInit dictionary with the addition of the following properties:

  • activateAfter
    • : A DOMHighResTimeStamp indicating a timeout in milliseconds after which the fetch request should be sent. The fetch can be sent earlier on navigating away. The actual sending time is unknown, as the browser may wait for a longer or shorter time, for example, to optimize the batching of deferred fetches. If the activateAfter property is not provided, the deferred fetch waits until the end of the page visit (including entering the bfcache).

Exceptions

  • RangeError
    • : Raised when a negative activateAfter is provided.

Examples

Defer a GET request until the page is destroyed or enters the bfcache

In this example, no DeferredRequestInit object is provided and no timeout is used:

fetchLater("/send_beacon");

Defer a POST request for around 1 minute

In this example we create a Request, and provide an activateAfter value to delay sending the request for 60,000 milliseconds (or one minute):

fetchLater("/send_beacon", {
  method: "POST",
  body: getBeaconData(),
  activateAfter: 60000, // 1 minute
});

[!NOTE] The actual sending time is unknown, as the browser may wait for a longer or shorter period of time, for example to optimize batching of deferred fetches.

Specifications

Browser compatibility

See also

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

资料来源与适用范围

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

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

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