demo · v135

Queue a deferred request

fetchLater() queues a request that fires after a delay or when the document is hidden / unloaded — no service worker, no keepalive hack. Schedule one below; the live capability pill tells you whether the call actually queued in this browser.

Origin trial fetchLater shipped behind an origin trial and a flag — enable via chrome://flags/#fetch-later-api. If the API is unavailable, this page reports that directly and offers a normal fetch() send to the same backend receiver.
fetchLater: ?

queue log

the code

const handle = fetchLater("/log", {
  method: "POST",
  body: JSON.stringify({ event: "page_close" }),
  activateAfter: 30_000,
});

// Call handle.abort() to cancel before activation.
// If page unloads first, the browser flushes the request.

see also