// the find
zenorocha/clipboard.js
:scissors: Modern copy to clipboard. No Flash. Just 3kb gzipped :clipboard:
clipboard.js is a 3kb library that wraps the browser clipboard API behind a simple data-attribute interface. No dependencies, no Flash. It's been the default answer to 'how do I add a copy button' for a decade and 34k stars suggests it found product-market fit immediately.
Event delegation means you can attach to hundreds of buttons with a single instance — no memory leak footgun. The data-attribute API (`data-clipboard-text`, `data-clipboard-target`) means zero JS for simple cases. The imperative API with `target`/`text` callbacks covers the dynamic cases cleanly. `destroy()` is present and documented, which most tiny libraries skip.
The library still uses `document.execCommand('copy')`, which is deprecated — MDN has flagged it for years and browsers could remove it. The modern `navigator.clipboard.writeText()` async API isn't used at all, which means no support for images or rich content and no path forward when execCommand finally dies. No TypeScript source — there's a `.d.ts` file bolted on afterward, which means the types lag behind the implementation. Last meaningful code change was years ago; the repo is effectively in maintenance mode, which is fine until execCommand goes away.