Mechanical ComparisonAsync Clipboard API and User Activation: Baseline · WidelyBeacon API and visibilitychange Lifecycle: Baseline · Widely

Async Clipboard API and User Activation vs Beacon API and visibilitychange Lifecycle

Mechanical Verdict

sendBeacon dispatches background requests without user gesture, whereas Async Clipboard requires transient user activation.

Try Async Clipboard API and User Activation LabTry Beacon API and visibilitychange Lifecycle LabRead Async Clipboard API and User Activation DissectionRead Beacon API and visibilitychange Lifecycle Dissection

Structured Comparison Matrix

DimensionAsync Clipboard API and User ActivationBeacon API and visibilitychange Lifecycle
Mental ModelPromise-based OS clipboard access gated by HTTPS, document focus, and transient user activation tokens, supporting deferred Blob resolution via ClipboardItem.Prevent dropped analytics and broken bfcache on tab close by handing <= 64 KB POST payloads to the browser network process on visibilitychange.
Maturity & DomainBaseline · Widely · Web APIs
Chrome 66+ (writeText), 76+ (ClipboardItem) · Firefox 63+ (writeText), 127+ (ClipboardItem) · Safari 13.1+
Baseline · Widely · Web APIs
Chrome 39+ · Firefox 31+ · Safari 11.1+
Prerequisites
When Not to UseWhen not to use navigator.clipboard.readText(): Never poll clipboard contents on focus; it triggers intrusive browser permission prompts and erodes user trust.When not to use sendBeacon(): If your code needs the HTTP response status, custom Authorization headers, or payloads > 64 KB, use fetch(..., { keepalive: true }) (for headers/status within 64 KB) or flush eagerly before exit; unlike Async Clipboard, sendBeacon() requires no transient user activation.

Engine Mechanics & Trade-Offs

Async Clipboard API and User ActivationBaseline · Widely

The browser gates OS pasteboard IPC behind HTTPS, document focus, and a decaying transient activation token, re-encoding images to strip exploit payloads.

Key Pitfalls: Awaiting before calling write(): Even a 300ms fetch() before navigator.clipboard.writeText() triggers NotAllowedError in Safari; wrap the fetch() inside ClipboardItem. Unfocused document or iframe: Calling clipboard methods inside an iframe without allow="clipboard-write" or while DevTools holds focus throws NotAllowed

Beacon API and visibilitychange LifecycleBaseline · Widely

The renderer hands the serialized payload to the browser network process with a 64 KB keepalive cap so the OS socket survives tab destruction.

Key Pitfalls: Wiring sendBeacon() to unload: Any unload listener disqualifies the document from bfcache in Chrome and Firefox; use visibilitychange and pagehide. Ignoring the boolean return value: sendBeacon() never throws on quota overflow, it silently returns false when the 64 KB buffer is exhausted.