I'm writing a js script that analyzes various DOM nodes of potentially big websites. The script gets included into the HTML source code and does its work when the page gets loaded in the browser.
The problem is: it takes several minutes to complete and freezes the whole tab during the process. I could live with that, but if I apply it to bigger websites it freezes my whole desktop, rendering the PC unusable.
I thought of the following solutions, which all more or less don't work for me:
- Split the work across multiple invocations of the script. This is a lot of work, so I'd rather avoid it.
- Run the script in a WebWorker. Not an option for me, I need access to all DOM nodes, which is impossible in WebWorkers according to MDN.
How can I run a js script that takes several minutes in the browser with a web page loaded, without freezing my whole system?
Thanks in advance!