How do I run this inside a webworker?
See original GitHub issueit’s looking for the document inside the webworker code, presumably to check if it’s supported.
Uncaught ReferenceError: document is not defined
Is there a way of avoiding this, I would like to run the reconnectingwebsocket inside a webworker
Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Using Web Workers - Web APIs - MDN Web Docs
Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering ......
Read more >HTML Web Workers API - W3Schools
When executing scripts in an HTML page, the page becomes unresponsive until the script is finished. A web worker is a JavaScript that...
Read more >How Web Workers Work in JavaScript – With a Practical JS ...
A web worker is a piece of browser functionality. It is the real OS threads that can be spawned in the background of...
Read more >A Simple Introduction to Web Workers in JavaScript - Medium
The web worker feature revolves around an object called Worker . When you want to run something in the background, you create a...
Read more >How to execute a function with a web worker on a different ...
When we run code in a worker we can't manipulate DOM elements, use window objects, etc. The context in which workers run are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i don’t know if this problem has been fixed. But you cannot access DOM in a webworker thats why you can’t use document. But there is a workaround. You can create a fake DOM in a js file the use importScripts to import the js file to your webworker.This will enable you use most DOM objects.Below is the code for the fake DOM
robust-websocket
runs in a webworker (it usesCustomEvent
for eventing).