user2650994
user2650994

Reputation: 146

Using SVG.js within a Worker

My application has a websocket connection to the server, on which it periodically receives a large JSON payload, which it then transforms into a SVG visualization using SVG.js. Doing this on the main JS thread freezes the UI for a noticeable (5+ seconds) time. I would like to utilize a Worker to do the transformation in a thread, and then do a wholesale replace of the current SVG with the updated SVG on completion.

My question is this - SVG.js expects to modify the DOM directly. Is there a way to make it operate in a 'sandbox' of sorts, which will not affect the existing DOM until work is completed?

Upvotes: 0

Views: 365

Answers (1)

Fuzzyma
Fuzzyma

Reputation: 8474

svg.js needs a dom to work. It will not work in a Worker. We have svgdom which mimicks a dom. This could work but then you need all sorts of server libs loaded into your client and thats not advisable.

So the answer is: No, there is no good way to achieve what you want

Upvotes: 1

Related Questions