I have for a long time heard from certain segments of the community that they would appreciate being able to do various “zip” related things in the browser. The exact ask is fuzzy, often coming in the form:
I’d like to have some version of the capabilities provided by Node’s zlib API. To summarize, that includes:
- GZIP compression/decompression
- DEFLATE compression/decompression
- “Raw” DEFLATE compression/decompression (I don’t know what this is)
- Both streaming versions of these, and binary data chunk versions (i.e. one large ArrayBuffer -> another smaller/larger ArrayBuffer).
I’d like to be able to create “.zip” files in my browser, so that I can prompt users to download them.
An example use case would be clicking “export these statistics to a zip of csv files”
This also allows the creation of .zip-based files, for example Microsoft Office files, or .cbz comic book files, or most Ebook formats
You can accomplish these today using user-space libraries, e.g. zip.js or zlib.js (“new users can only put two links in a post”). There are probably some Emscripten and/or asm.js versions floating around that are even very fast.
However, I think it would be valuable to provide these natively for the web platform. To me, it’s especially compelling to think of all that juicy C(++) code being shipped with every browser already, at least for the zlib case, which with just a bit of extra effort could be exposed for web platform authors. That way, you wouldn’t need to include a large script to download, or have to deal with web workers, or anything of the sort.
I often this kind of API as my favorite example of things that would be perfect to add to the web platform, but nobody has made the time to gather implementer interest or spec them yet.
As such I was hoping to get the ball rolling on this conversation. What do people think of the above asks and use cases? Are any implementers interested in this? Are there objections stemming from the fact that you can do this in JS today, even if it’s not as fast or seamless as you might like? Has this secretly been something you’ve always dreamed about and never dared to ask for?