Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. DeferredRequestInit

DeferredRequestInit

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheDeferredRequestInit dictionary of thefetchLater() API represents the set of options that can be used to configure a deferred fetch request.

TheDeferredRequestInit object is passed directly into thewindow.fetchLater() function call as the second argument.

Instance properties

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

activateAfterOptional

ADOMHighResTimeStamp indicating a timeout in milliseconds after which the fetch request should be sent. The fetch can be sent earlier on navigating away. Theactual 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 theactivateAfter property is not provided, the deferred fetch waits until the end of the page visit (including entering thebfcache).

Exceptions

RangeErrorDOMException

Raised when a negativeactivateAfter is provided.

Examples

Defer aGET request until the page is destroyed or enters the bfcache

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

js
fetchLater("/send_beacon");

Defer aPOST request for around 1 minute

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

js
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

Specification
Fetch
# deferred-fetch

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp