There are several ways that you can manipulate the DOM in workers:
- Import a copy of the DOM from the worker (very poor performance),
- Parse the “document line” into the new DOM (very poor performance) and
- Send and receive DOM manipulation commands in a browser (best solution).
This may seem silly, but all you need to do is send the arguments "DOM-related functions" to the browser and return the result to your worker;
source share