v149 · Clipboard · Lazy Read Demo
Lazy Read Demo
Step through the new lazy clipboard read: call read() to get available MIME types without fetching data, then click a type button to fetch only that format's data via getType().
Chrome 149 required for the lazy read behaviour. This demo requires clipboard read permission — Chrome will prompt. In older browsers,
read() eagerly fetches all formats; you'll still see the same API, but the performance improvement won't apply.
live demo
Step 1: Copy something to your clipboard
—
Step 2: Call clipboard.read() — types only, no data
—
Step 3: Call getType() for a specific format
—
code
// Step 1: read() — available types only, no data fetched
const items = await navigator.clipboard.read();
for (const item of items) {
console.log('Available types:', item.types);
// ['text/plain', 'text/html'] — data not yet loaded
// Step 2: getType() — fetches ONLY this format
if (item.types.includes('text/plain')) {
const blob = await item.getType('text/plain');
const text = await blob.text();
console.log('text/plain data:', text);
// Other formats were never read from the OS
}
}
see also
- Eager vs. Lazy Comparison — performance impact side by side
- ChromeStatus entry
- MDN — Clipboard.read()
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗