Web Workers are for running scripts in the background independently of any user interface scripts.
Sample Code snaps for Web Worker :
Create a Web Worker Object
var worker = new Worker('worker.js');
Receive notifications from the worker,
worker.onmessage = function (oEvent) {
//Called back by the worker
;
Start Worker
worker.postMessage(""); // start the worker
start it by calling the postMessage() method: