0

is it possible to parse a HTML page that was fetched via a jQuery GET call in a web worker? I know that you can't access the DOM in a web worker, but I think it should be possible to pass the html to the worker and process it with a selector engine like sizzle. I don't need to manipulate the main page's DOM here. Or is sizzle also not available for use in this case?

The problem is that my processing/parsing is so heavy, that the UI hangs for about 10 seconds, so doing this stuff in a separate Thread would be a good idea. So if this is possible, how could I implement this?

Kirschi
  • 1,088
  • 3
  • 12
  • 32
  • Possible duplicate of [DOM-like APIs for HTML string content inside a web worker](http://stackoverflow.com/questions/12703785/dom-like-apis-for-html-string-content-inside-a-web-worker) – James Thorpe Mar 21 '17 at 12:27
  • Somewhat related: http://stackoverflow.com/questions/18056922/is-there-a-way-to-create-out-of-dom-elements-in-web-worker/18102539#18102539 – sideshowbarker Mar 21 '17 at 14:19
  • The gist of it is that no DOM implementations in (I think) any browsers are thread-safe, so you can’t parse into the native DOM from a worker. So, as linked to from another comment here, you can use jsdom or personally I would recommend trying https://github.com/inikulin/parse5 (which is a parser for Node but you can use Browserify to compile it for use in a browser-based web app – sideshowbarker Mar 21 '17 at 14:34

0 Answers0