Result Size: 300 x 150
x
 
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript веб-воркери API</h2>
<p>Рахувати числа: <output id="result"></output></p>
<button onclick="startWorker()">Старт Worker</button>
<button onclick="stopWorker()">Стоп Worker</button>
<script>
let w;
function startWorker() {
  if(typeof(w) == "undefined") {
    w = new Worker("demo_workers.js");
  }
  w.onmessage = function(event) {
    document.getElementById("result").innerHTML = event.data;
  };
}
function stopWorker() {
  w.terminate();
  w = undefined;
}
</script>
</body>
</html>