Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions and allows long tasks to be executed without yielding to keep the page responsive.
Web Workers are background scripts and they are relatively heavyweight and are not intended to be used in large numbers. For example, it would be inappropriate to launch one worker for each pixel of a four-megapixel image.
Following is the syntax −
var worker = new Worker('bigLoop.js');