What is a Web Worker?
When you execute a script in an HTML page, the state of the page is not responsive until the script is complete.
Web Worker is a JavaScript running in the background, independent of other scripts, without affecting the performance of the page. You can continue to do anything you want to do: Click, select Content, and so on, while the Web worker runs in the background.
Counter:
<! DOCTYPE html>varW;functionStartworker () {if(typeof(Worker)!== "undefined") {//The following code detects if a worker exists, and if it does not exist-it creates a new Web worker object and then runs the code in "Demo_workers.js": if(typeof(w) = = "Undefined") {W=NewWorker ("/example/html5/demo_workers.js"); }//Add a "onmessage" event listener to the Web worker:W.onmessage =function(event) {document.getElementById ("Result"). innerhtml=Event.data; }; }Else{document.getElementById ("Result"). Innerhtml= "Sorry, your browser does not support Web Workers ..."; }}functionStopworker () {//To terminate the Web worker and release the browser/computer resources, use the Terminate () method:w.terminate ();}</script></body>"HTML5" Web Workers