Your digital bunker

Is JavaScript mining the future of monetization?


I always heard about background mining when it was about a malware or a software stealing its users' power without their consent. However, in the last few years adblockers became available for the on most devices and advertisement became less remunerative than ever. Many alternatives were proposed, like voluntary donations or pay-per-view optional plans, but they were not enough valid as is it uncomfortable to pay a fee for every content you want to view on the web.

Today many sites are experimenting with using visitors' CPUs to cryptocurrencies. This new way of monetizing websites seems to be fruitful enough and, if configured correctly, totally transparent to the user, without harming its hardware or compromising the experience while visiting your site.

In this article I'll explore the untasted world of background mining as a way to monetize, analyzing its pros and cons focusing on the users' point of view. I'm not affiliated to any of the services named here. I'm an huge fan of concrete examples and i think they are crucial to fully understand a subject.

Definition and how it works

JavaScript mining consist on embedding a cryptocurrency miner (written in JS/WebAssembly) in your site, with users sharing their hardware power to be able to navigate on your site.

You just have to embed a JS miner source and configure it to balance remunerativity and weight on users. This last step is important to ensure you're not bothering your users with a low-end hardware.
The script will generate hashes and send them to a server that checks if they're correct. It works similarly to mining pools, but in this case the site owner is the one which gets awarded for the shares.

It is nearly mandatory to mine a computationally hard cryptocurrency like Monero website, as CPU mining is still profitable. One of the simplest service of this type is Coinhive. They've documentation on how to embed their miner and a good explaination on how their miner pays them and their clients. I recommend you to check it later, those guys made a really good work.

Pros and cons


  • Easy to use and transparent way to monetize your website.
  • Nearly imperceptible on modern computers.
  • Remunerative on long-term because a cryptocurrency may gain enormous values in months or even weeks.


  • May be annoying or even dangerous for your users if not configured correctly.
  • Cryptocurrencies are really unstable, so they may lose even all of their value.

Implementations in different contexts

The most interesting part in JavaScript mining is that it only consists in calculating hashes. Ads need a visual reply, mining doesn't and it can be applied in many different contexts. I have to mention again the guys at Coinhive as some of these ideas are already implemented in their sites, while others were born by my own reflections.

  • Captchas: They're probably the most boring part of the internet, altough they've been necessary to prevent bots. But what if instead of solving a test to prove you're human your CPU solves some hashes to you, making bots unprofitable?

  • Link shorteners: Instead of watching 5 seconds of spammy ads, you could solve some hashes with your CPU. It is even more secure as some link shorteners may contain ads with malwares.

  • 'Voluntary' donations: A satisfied user may decide to 'donate' to your site just leaving it open and mining in background. It is not as remunerative as donating via PayPal or any other credit card, but is much more immediate.

  • Alternative to offers / pay to win: Instead of watching videos or downloading apps, you could get credits in a game or any similar prize mining. Profits won't be so different on high-end CPUs or on any hardware that's suitable for gaming.

Conclusion and further readings

This new way to monetize is expanding quickly and it seems to have less negative sides than expected. But adblockers may easily implement a script blocker, making it not remunerative anymore. We must hope that both users and site owners don't get too greedy, ruining what seems to be a good revolution in internet earnings.

CryptoNote whitepaper (reading it may help you understanding why CPU mining could still be profitable)