Here’s a handy JS package for “copy to clipboard” functionality that’s lightweight and installable from npm.
It also appears to have good legacy browser support plus a means for checking/confirming support too, which should assist if your approach is to only add a “copy” button to the DOM as a progressive enhancement.
(via @chriscoyier)