LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

copy.js - simple copy text to clipboard in the browser

Note: This post is over 11 years old. The information may be outdated.

DEPRECATED (2025): This article describes an unmaintained library from 2016. For modern copy-to-clipboard functionality, use the native navigator.clipboard API instead, which is supported in all modern browsers and requires no dependencies.

Simple copy to clipboard. No Flash.

Install

You can get it on bower.

bower install copy --save

Or npm, too.

npm install copy-js --save

If you're not into package management, just download a ZIP file.

Setup

First, include the script located on the dist folder.

<script src="dist/copy.min.js"></script>

Or load it from CDN provider.

<script src="//cdn.rawgit.com/duyetdev/copy.js/master/dist/copy.min.js"></script>

Usage

Just copy:

copy('hello world.')

With callback:

copy('hello world', function (err) {
  if (err) console.log('Some thing went wrong!')

  console.log('Copied!')
})

That's it!

Modern Alternative (2025)

Instead of using copy.js, use the native Clipboard API:

// Copy text to clipboard
navigator.clipboard.writeText('hello world')
  .then(() => console.log('Copied!'))
  .catch((err) => console.error('Failed to copy:', err))

The native API is supported in all modern browsers and requires no external dependencies.

Visit project source code here: https://github.com/duyet/copy.js

Feb 17, 2016·10 years ago
|Javascript|
Node.jsNpmJavascript
|Edit|

Related Posts

Yarn: A new package manager for JavaScript

Facebook has launched Yarn

Oct 13, 2016·9 years ago
Read more

calc.js - evaluate expressions for Math

Flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices. Powerful and easy to use.

Mar 27, 2016·10 years ago
Read more

Resting và Spreading JavaScript Objects

Resting và spreading càng ngày được ưa chuộng vì sự tiện lợi của nó, sau đây là 7 tricks với JavaScript objects.

Mar 27, 2019·7 years ago
Read more

Javascript Weekly #9

Javascript Weekly #9: Date-DNS, chi tiết về các bản cập nhật mới của V8, React và Angular. ![](https://2.bp.blogspot.com/-3n1yGifwJdY/WEtxXVdp38I/AAAAAAAAgt4/ijum1QPHo6ENxNmPawMuGeKyxKfw2tfEACLcB/s1600/Screenshot%2Bfrom%2B2016-12-10%2B10-06-59.png) ## [date-fns: A Modern...

Dec 10, 2016·9 years ago
Read more
On this page
  • Install
  • Setup
  • Usage
  • Modern Alternative (2025)
On this page
  • Install
  • Setup
  • Usage
  • Modern Alternative (2025)