Encryption of `window` and` document` in web workers

Are there solutions for implementing window and document objects in ways that do not use the DOM after they are initialized, but have compatible interfaces? They would be useful for using heavy libraries such as MathJax in a web worker.

+6
source share
1 answer

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;

0
source

Source: https://habr.com/ru/post/944739/


All Articles