
JSZip: Create, read and edit .zip files with JavaScript - saltcookie
http://stuk.github.io/jszip/
======
sheetjs
We use jszip for parsing xlsx/xlsm/xlsb files in the browser (Excel 2007+
files are zip files that contain XML or binary files in specific locations):
[https://github.com/SheetJS/js-xlsx](https://github.com/SheetJS/js-xlsx)

JSZip works well for small files, but unzipping XLSB files larger than 50M
seem to cause out of memory issues in Firefox

~~~
TazeTSchnitzel
Have you considered zip.js instead? It claims to work with files up to 4GB. It
also can zip large files without any issues for me in Firefox.

~~~
sheetjs
When we first evaluated options, zip.js only supported IE9+ (and IE6-8 were
still relevant browsers) while JSZip supports IE6+. In fact, the Base64 text
box was introduced in [http://oss.sheetjs.com/js-
xlsx/](http://oss.sheetjs.com/js-xlsx/) specifically to test IE6-9 (which do
not support the HTML5 File API)

~~~
TazeTSchnitzel
I see. Inevitably its support for older browsers makes it slower, however.

------
allthatisgold
I tried JSZip not too long ago for my side project and it was quite slow. I've
been using [http://gildas-lormeau.github.io/zip.js/](http://gildas-
lormeau.github.io/zip.js/) and I'm very happy with it. I hope to release my
web app some time this week.

~~~
TazeTSchnitzel
zip.js seems to be the better of the two. It uses typed arrays, so it's
performant and I can zip large (140MB) files quickly and without hanging the
browser.

------
artellectual
Actually, one of the best use case for this is, when a user wants to upload
multiple images / files, we can use the html5 file api with zip js generate 1
zip file and upload just that one file and extract on the server. It will be
much faster. And actually you can use this in the web worker api so it doesn't
block the Ui thread

------
nanidin
Potential use case: instead of using CSS sprite maps (putting all of your
images into one image to reduce the number of http requests generated by your
page, then using css magic to select regions inside of that image), image
files could be zipped into an image package that is delivered to the client,
who unzips it and uses the images inside. This would cut down on the number of
requests made, but allow the images to be used as normal images instead of as
images within a sprite sheet.

~~~
moron4hire
The crazy thing: in this thread, you are all right. The state of sending
multiple files sucks. ZIP is the closest thing we have to a universal
standard, if only because Windows refuses to ship with support for anything
that is meaningful.

~~~
zo1
I seem to recall them getting a big fat law suit when they tried to bundle
things with their OS. Perhaps they don't bundle things anymore for a reason?

------
bhouston
We've used [https://github.com/EvanOxfeld/node-
unzip/issues](https://github.com/EvanOxfeld/node-unzip/issues) in production
and we've had a surprising number of corrupt zip files created by it. We've
switched to using a barely wrapped zip command line tool.

Is PSZIp better?

------
ff7c11
It's really fast at reading zip files created by Google takeout. I use it at
[http://theyhaveyour.info](http://theyhaveyour.info) as it works perfectly
with the FileReader API. For reading only though - haven't tried writing with
it.

------
moron4hire
Holy carp on a stick, that was so easy. You've made my day today.

BTW, here is how I make files download with the filename that I want:
[https://github.com/capnmidnight/JWD/blob/master/html5/deskto...](https://github.com/capnmidnight/JWD/blob/master/html5/desktop.js#L6-L16)

The call to the "a" function on line 8 is just generating an HTML anchor tag.
You should be able to figure it out from there.

------
ragecore
Why not unrar and untar using javascript as well?

[https://github.com/varunmayya/bitjs](https://github.com/varunmayya/bitjs)

------
napoleond
If you're purely interested in client-side compression in the browser (i.e.
compatibility with server libraries/filesystem tools is not important) it's
possible to get better compression in less time using
[http://pieroxy.net/blog/pages/lz-
string/index.html](http://pieroxy.net/blog/pages/lz-string/index.html)

------
moron4hire
This is exactly a project I was about to embark upon to generate ePub files
from client-side JS. Thanks!

~~~
davidw
Interesting - can I ask what you're working on? I'd be a bit worried about
potentially memory issues with image-heavy ePubs.

~~~
moron4hire
A minimalist writing tool to train beginner novelists on completing writing
projects:
[https://www.justwritedammit.com/#main/about](https://www.justwritedammit.com/#main/about)

I'm specifically targeting novelists (at least, right now), so pictures and
complex layouts shouldn't be an issue. I want it to be something you can
easily pick up, plod away through, maybe pay someone to do some editing for
you, and then walk you through pushing it out on the Amazon Kindle Store.

------
nawitus
Does this handle very large files on Node.js? npm for one fails with large
files, by "large" I mean something like a few hundred megabytes. It's very
problematic especially on Windows.

------
klunger
Am I misunderstanding this, or could this be used to send a client a large
amount of data in a zip file? Let's say the client is using WebView...

------
na85
>JavaScript today is capable of generating a lot of data. The easiest way to
deliver multiple files to your users is in a zip file. Instead of wasting
server resources and bandwidth you can get the client to do it for you.

... Am I not understanding what they're saying here or do the authors really
not understand how the internet works?

It looks to me like they're saying "don't bother letting your users download
zip files. Save your bandwidth! Just get them to send themselves a zip file,
client-side!"

~~~
prezjordan
Consider something like bootstrap, which allows you to customize your download
before sending you a zip file.

The assets are already loaded (since you're viewing the bootstrap demo page),
so instead of making a request to another server to generate some sort of
compressed file for you, that labor is offloaded to the client.

~~~
nacs
Except you're unnecessarily bogging down the user's browser to a far greater
extent (base64 encoding/decoding everything on a possibly underpowered CPU/IO)
than the amount of work it would take to do it on the server (pure binary
processing on a high end CPU).

I'm guessing Bootstrap can do it because they know most Bootstrap users are
developers with decent PCs but for a more mainstream audience, it would be
problematic.

~~~
kalleboo
Have you used Mega.com? It does in-browser (JavaScript) encryption of uploads
and downloads. And I can still hit 5 MB/s throughput. JavaScript can handle
Zip compression easily.

For most users, bandwidth is in shorter supply than CPU. Especially on mobile
(your constrained CPU/IO case), where people are using 3G or worse, which is
often even billed by the MB.

------
clxl
Atwood's law in action

------
collyw
Is this really news? Almost every server side language out there will have a
zip library, and I doubt any of those got mentioned on HN.

~~~
kalleboo
Server-side languages, yes. There are lots of those, so each one doesn't
impact many. But there's only one client-side language on the web, so it
impacts everyone.

~~~
collyw
So we are reporting it just because it is JavaScript.

~~~
avmich
Yes. JavaScript is lingua franca of the Web, so it may be important to have a
particular functionality implemented in JavaScript.

This way, if you, say, want to take a part of the program and use it
elsewhere, you have the advantage of the same language. If you want to ask a
question about the program, you can count on other people knowing the
language. If you want to illustrate something using a program, you have a
common ground here.

