CodeMay 8, 2026 ยท Updated Oct 14, 2026 ยท 4 min read

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.

๐Ÿ”Œ
Try the API Request Builder
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01Fetch: Check response.ok02Storage: How Much Fits Where03Observers Instead of Polling04Keeping Work Off the Main Thread05Sending Data When the Page Closes06Support at a Glance

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):

APIChromeFirefoxSafari
fetch()423910.1
AbortSignal.timeout()12410016
IntersectionObserver515512.1
ResizeObserver646913.1
MutationObserver26147
navigator.clipboard.writeText()666313.1
Element.animate()364813.1
Web Workers23.54
requestIdleCallback()4755preview only, behind a flag
navigator.sendBeacon()393111.1
OPFS (StorageManager.getDirectory())8611115.2
structuredClone()989415.4
scheduler.yield()129142not supported
IndexedDB24168

Frequently Asked Questions

Fetch or Axios?+
Start with fetch: it is built in, and AbortSignal.timeout() now covers timeouts. Remember that fetch resolves on 404 and 500 responses, so check response.ok. Axios adds conveniences such as interceptors and automatic JSON handling, which can be worth it in a larger app.
Is localStorage secure?+
No. Any script running on the page can read it, including injected or compromised third-party scripts. Keep session tokens in HttpOnly cookies, as OWASP recommends, and store only non-sensitive preferences in localStorage.
When to use Web Workers?+
When a job would block the main thread for more than about 50 ms, the long-task threshold in the W3C Long Tasks specification: parsing large CSV or JSON files, image processing, search indexing or heavy calculations.
Try it yourself

Use the API Request Builder โ€” free, no signup required.

โšก Open API Request Builder
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.