-
I'm using a compressed sql.js database in my website that I want to decompress. I was using pako (with a cdn) to do so, but it's blocking my main thread, making the site unresponsive for a few secs.
Can you tell me how to do so using fflate asynchronously? And where can I find the inflate-only cdn for fflate? I found this SO answer but couldn't figure out how to do it for my database. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There isn't really an inflate-only CDN. I've been waiting for a while for a CDN service to offer the ability to tree-shake based on the function names specified in a query parameter or something to offer exactly that kind of functionality, but unfortunately I don't think it exists; you'll probably have to use the 11kB minzipped CDN bundle. You can do that by adding the HTML provided in the README to your page: <script src="https://cdn.jsdelivr.net/npm/fflate@0.8.2/umd/index.js"></script> Beyond that, to make your above code use const decompressedBuffer = await new Promise((resolve, reject) => {
fflate.inflate(buffer, (err, result) => err ? reject(err) : resolve(result));
}); |
Beta Was this translation helpful? Give feedback.
There isn't really an inflate-only CDN. I've been waiting for a while for a CDN service to offer the ability to tree-shake based on the function names specified in a query parameter or something to offer exactly that kind of functionality, but unfortunately I don't think it exists; you'll probably have to use the 11kB minzipped CDN bundle. You can do that by adding the HTML provided in the README to your page:
Beyond that, to make your above code use
fflate
and not hang the page, all you'd change is thedecompressedBuffer
line.