Stop Web Workers in HTML5


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 don't stop by themselves but the page that started them can stop them by calling terminate() method.

worker.terminate();

A terminated Web Worker will no longer respond to messages or perform any additional computations. You cannot restart a worker; instead, you can create a new worker using the same URL.

Updated on: 28-Jan-2020

955 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements