Cryptojacking Scripts

Cryptojacking scripts

Cryptojacking scripts allow you to quickly install a miner on your website.

Coinhive’s set of AuthedMine scripts is the only solution I can recommend. The reason is the miner will never start without getting explicit consent from the page visitor. 

AuthedMine script

Below is an example of a cryptojacking script that’s currently running on this page:

<script src=""></script>
	var miner = new CoinHive.Anonymous('nom2KNN1a8m7mJIHdNcI4FbluQ7lmpYA', {throttle: 0.5});

	// Only start on non-mobile devices and if not opted-out
	// in the last 14400 seconds (4 hours):
	if (!miner.isMobile() && !miner.didOptOut(14400)) {

What is the code doing?

Line 1 is including a JavaScript cryptomining library from Coinhive.

Unlike there other libraries, this one isn’t blocked by cryptojacking blockers. Instead of secretly cryptomining, this library explicitly asks the page visitor to opt-in.

Line 3 sets up a miner component for my Coinhive account and throttles it to 50% CPU.

Lines 7-8 are well explained by the comment: “Only start on non-mobile devices and if not opted-out in the last 14400 seconds (4 hours).”

Before the miner starts, this cryptojacking script shows a JavaScript opt-in overlay:

Cryptojacking scripts - AuthedMine opt-in

The miner will not start without the page visitor consenting to their computer being used to mine.

About the Author

Ray Li

Ray is a software engineer and data enthusiast who has been blogging for over a decade. He loves to learn, teach and grow. You’ll usually find him wrangling data, programming and lifehacking.

Comments 2

    1. Post

Leave a Reply

Your email address will not be published. Required fields are marked *

nineteen − nine =