I have an HTML table with different columns and rows. The table can be edited inline by a user. When a user edits the table, I calculate some sums on the rows of table.
The function that calculates the sums was in the main script and took a lot of time making the browser unresponsive. To solve this performance issue, I have created a web worker in JavaScript to calculate the sums on the table.
The problem is that the web worker cannot access the DOM. I'm looking for a way to pass a jQuery object table to the web worker.
If I try to pass the jQuery object I receive an error:
Uncaught DataCloneError: Failed to execute 'postMessage' on 'Worker': An object could not be cloned.
How I can pass the table to the Web Worker?
Thank you
[EDIT adding some further information ]
The sum take a long time because the table has a lot of rows and calculate different sums (total, subtotal,etc). The values to sum are stored in table (so worker need to access to table to perform the calculation).
My idea is to pass DOM object to worker to calculate sums. After calculation, worker return the sums to main thread in order to update values in the DOM.