π· About HTML Web Workers API - 2
A Thread𧡠π
π Terminate a Web Worker
β When a web worker object is created, it will continue to listen for messages (even after the external script is finished) until it is terminated.
β To terminate a web worker, and free browser/computer resources, use the terminate() method.
π Check Web Worker Support
β Before creating a web worker, check whether the user's browser supports it.
π Reuse the Web Worker
β If you set the worker variable to undefined, after it has been terminated, you can reuse the code.
π Web Workers and the DOM
β Since web workers are in external files, they do not have access to the following JavaScript objects:-
β’ The window object
β’ The document object
β’ The parent object
π Full Web Worker Example Code
β We have already seen the Worker code in the .js file.
β Below is the code for the HTML page.
Thanks for reading this thread β€οΈ
If you like it , make sure you:
π· Like the tweet
π· Retweet the first tweet β‘
For more content , follow:
@MrunayU