Copying text to the user's clipboard Here's my code.

javascript:x=document.createElement("script");x.src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"; document.getElementsByTagName("head")[0].appendChild(x);copy(1)


Is this the correct way? Are there any flaws in it?

Running:

copy(1)


doesn't work by itself so that's not a possibility, and 

javascript:x=document.createElement("script");x.src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"; document.getElementsByTagName("head")[0].appendChild(x);copy(1)


appears to be the best so far.
Looks fine, except for polluting the namespace, you could consider using a self executing anonymous function.

javascript:(function(){x=document.createElement("script");x.src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"; document.getElementsByTagName("head")[0].appendChild(x);copy(1);})();