Accessing localStorage from a webWorker

Web workers only have access to the following:

The window or parent objects are not accessible from a Web worker therefore you can’t access the localStorage.

To communicate between window and the workerglobalscope you may use postMessage() function and onmessage event.

Accessing the DOM and window would not be thread safe, since the child thread would have the same privileges as its parent.

Leave a Comment