Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.81k stars 1.3k forks source link

Using Jszip in Angular to export 1-2 MB files considerably slows down UI #902

Closed bastientardits closed 1 year ago

bastientardits commented 1 year ago

Hello, I have been working on an Angular service who's goal is to export several html files into a zip folder. The service works perfectly fine, however when I download large folders, the UI is considerably slown, most likely due to the export clogging the memory. I have read the documentation about the limtations of jszip. However, the solutions offered there seem to only work in node.js with server-side node streaming. Has anybody found a solution for this? Functions like https://stuk.github.io/jszip/documentation/api_jszip/generate_node_stream.html are non existant in angular client side. If yes, I would very much appreciate a link to an example repo. The issue is non existant once the page using the service is refreshed, but it seems a rather harsh solution because it really disturbs the UI. Thanks

linhub15 commented 1 year ago

It might be possible to move the execution into a Web Worker.

The execution will happen asynchronously and when the Promise resolves you can postMessage() back to the component that registered the worker.

bastientardits commented 1 year ago

Hi @linhub15 thanks for your comment. Unfortunately I haven't found the answer to this specific problematic, but I did find out what the problem was on my end. Some of the content generated on the website (graphs with ngx-graph) that I put on the html exported files as svg was never actually destroyed and completely clogged the memory when generating the jsZIP. It all works fine currently for me.