A modern approach to copy text to clipboard
No Flash. No dependencies. Just 2kb
Copying text to the clipboard shouldn’t be hard. It shouldn’t require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn’t depend on Flash or any bloated framework.
That’s why clipboard.js exists.
If you’re not into package management, just download a ZIP file.
First, include the script located on the dist folder.
Now, you need to instantiate it using a DOM selector. This selector corresponds to the trigger element(s), for example：
Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. But guess what? If you have hundreds of matches, this operation can consume a lot of memory.