Essential Web APIs Every Frontend Developer Should Know
The browser APIs a frontend developer reaches for most, with measurements from Chromium 141: fetch() resolving on a 404, localStorage holding exactly 5,242,880 characters, and a beacon refused once 64 KiB was in flight. Support data comes from MDN.
Fetch: Check response.ok
fetch() only rejects when the request cannot be made at all. We requested a missing URL in Chromium 141 and the promise resolved normally, with ok: false and status: 404, so code that only catches errors treats a 404 or a 500 as success. Check response.ok before parsing, and give every request a deadline with AbortSignal.timeout():
const res = await fetch(url, { signal: AbortSignal.timeout(8000) });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
A timed-out request rejects with a TimeoutError DOMException. Build and test requests, including headers and bodies, with the API Request Builder.
Storage: How Much Fits Where
We filled localStorage in Chromium 141 until it refused: it held 5,242,880 characters of keys and values, exactly 5 ร 1024 ร 1024, before throwing QuotaExceededError. It is synchronous, so large reads and writes block the page, and it is shared by every script on the origin. IndexedDB is asynchronous, stores structured data and blobs, and draws on a per-origin quota that browsers size from free disk space; navigator.storage.estimate() reports it (0.3 GB on our small test disk, far more on a typical laptop). The Origin Private File System (navigator.storage.getDirectory()) adds fast file-style storage, with synchronous access handles inside workers.
Do not keep session tokens or personal data in localStorage: any script that runs on the page, including a compromised third-party one, can read it. OWASP's HTML5 security guidance recommends keeping session identifiers in cookies marked HttpOnly, which scripts cannot read.
Observers Instead of Polling
IntersectionObserver reports when an element enters or leaves the viewport (lazy loading, infinite scroll, impression tracking), ResizeObserver when an element changes size, and MutationObserver when the DOM changes. All three replace scroll or timer polling with callbacks the browser batches, and all three have been in every major browser for years (table below).
Keeping Work Off the Main Thread
A task that runs longer than 50 ms counts as a long task in the W3C Long Tasks specification, and long tasks are what make clicks feel laggy. Move heavy parsing, image processing or search indexing to a Web Worker, and break up the rest. scheduler.yield() lets a long function pause so input can be handled, but MDN's compatibility data lists it only in Chrome 129 and Firefox 142, not Safari, so fall back to setTimeout. requestIdleCallback() runs low-priority work in idle time in Chrome and Firefox, while Safari has it only in a Technology Preview behind a flag (checked live on MDN on October 14, 2026).
const yieldToMain = () => globalThis.scheduler?.yield
? scheduler.yield()
: new Promise(r => setTimeout(r, 0));
Sending Data When the Page Closes
navigator.sendBeacon() queues a small POST that the browser keeps sending after the page is gone, which is why analytics use it, but it is a queue, not a guarantee. Beacons share the 64 KiB in-flight budget the Fetch Standard sets for keepalive requests. In our test a 60 KiB beacon was accepted; while it was still pending, a second beacon of only 10 KiB returned false and was never sent. Check the return value, keep payloads small, and send on visibilitychange when the page is hidden rather than on unload, which mobile browsers often skip.
Support at a Glance
First versions with support, from MDN's browser-compat-data 8.1.3 (released September 24, 2026):
| API | Chrome | Firefox | Safari |
|---|---|---|---|
fetch() | 42 | 39 | 10.1 |
AbortSignal.timeout() | 124 | 100 | 16 |
IntersectionObserver | 51 | 55 | 12.1 |
ResizeObserver | 64 | 69 | 13.1 |
MutationObserver | 26 | 14 | 7 |
navigator.clipboard.writeText() | 66 | 63 | 13.1 |
Element.animate() | 36 | 48 | 13.1 |
Web Workers | 2 | 3.5 | 4 |
requestIdleCallback() | 47 | 55 | preview only, behind a flag |
navigator.sendBeacon() | 39 | 31 | 11.1 |
OPFS (StorageManager.getDirectory()) | 86 | 111 | 15.2 |
structuredClone() | 98 | 94 | 15.4 |
scheduler.yield() | 129 | 142 | not supported |
IndexedDB | 24 | 16 | 8 |
Frequently Asked Questions
Fetch or Axios?
Is localStorage secure?
When to use Web Workers?
Use the API Request Builder โ free, no signup required.
โก Open API Request Builder- [1]MDN browser-compat-data 8.1.3 (npm @mdn/browser-compat-data, released Sep 24, 2026) โ
- [2]MDN, Window.requestIdleCallback() (compatibility checked live Oct 14, 2026) โ
- [3]WHATWG Fetch Standard: keepalive and the 64 KiB in-flight limit โ
- [4]MDN, Navigator.sendBeacon() โ
- [5]MDN, AbortSignal.timeout() โ
- [6]W3C, Long Tasks API (50 ms threshold) โ
- [7]WHATWG HTML Standard, Web storage โ
- [8]OWASP, HTML5 Security Cheat Sheet (local storage) โ