coderef

AbortSignal.timeout()Baseline · Newly available

The AbortSignal.timeout() static method returns an abort signal that automatically aborts after a specified duration.

Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Apr 18, 2024.

Browser support

DesktopChrome
1–123Not supported
124+Supportedsince Apr 16, 2024
Current: 155
Edge
12–123Not supported
124+Supportedsince Apr 18, 2024
Current: 154
Firefox
1–99Not supported
100+Supportedsince May 3, 2022
Current: 157
Safari
1–15.6Not supported
16+Supportedsince Sep 12, 2022
Current: 27
MobileChrome Android
18–123Not supported
124+Supportedsince Apr 16, 2024
Current: 155
Firefox Android
4–99Not supported
100+Supportedsince May 3, 2022
Current: 157
Safari iOS
1–15.6Not supported
16+Supportedsince Sep 12, 2022
Current: 27

How to use

Every current browser supports this, but it only became Baseline on Apr 18, 2024. Use it as a progressive enhancement, or keep a fallback if you support older devices.

Example

Full syntax and examples are on MDN: timeout static.

Feature detection

JS · check before using
if ("AbortSignal" in globalThis && "timeout" in AbortSignal) {
  // AbortSignal.timeout is available
}