Skip to content

Commit

Permalink
Create webworker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiPanneerselvam authored Apr 5, 2022
1 parent d2709d5 commit d2820c7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/webworker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var w;

function startWorker() {
if(typeof(Worker) !== "undefined") {
if(typeof(w) == "undefined") {
w = new Worker("demo_workers.js");
}
w.onmessage = function(event) {
document.getElementById("result").innerHTML = event.data;
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Workers...";
}
}

function stopWorker() {
w.terminate();
w = undefined;
}

0 comments on commit d2820c7

Please sign in to comment.