Live data from Hacker News

JSZip: Create, read and edit .zip files with JavaScript

stuk.github.io

11–20 of 57 posts

Re: JSZip: Create, read and edit .zip files with JavaScript

#11
post #8

Earlier quoted context omitted.

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.

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 problema…

Except that most clients are ridiculously overpowered compared to a heavily loaded server. Even the slowest 1.3ghz core 2 duo is better than a high end xeon if there are 10 users at one time.

Re: JSZip: Create, read and edit .zip files with JavaScript

#12
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

Re: JSZip: Create, read and edit .zip files with JavaScript

#13
post #10

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…

i'm surprised we don't have a cross-browser webarchive concept yet... especially with the emphasis on mobile.

Re: JSZip: Create, read and edit .zip files with JavaScript

#14
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

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

Re: JSZip: Create, read and edit .zip files with JavaScript

#15
post #10

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…

Some images formats already come with compression. Also, zip doesn't work with well with binary data. Using CSS to "subscript" into the sprite is a better solution.

Re: JSZip: Create, read and edit .zip files with JavaScript

#17
post #8

Earlier quoted context omitted.

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.

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 problema…

Once again, a hacker news commenter's idea of what in browser javascript performance is like is ridiculously 15 years out of date.

It's 2014 now. Your iphone is 10 times faster than your 1998 pentium 2. Even with the JS vm penalty.

Unless you're zipping 70mb files, there's no chance you're overwhelming anyone's browser.

The usecase for this is the same you'd have for any desktop application: A handy "binary file format" library. Data portability wins.

Re: JSZip: Create, read and edit .zip files with JavaScript

#18
post #15
post #10

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…

Some images formats already come with compression. Also, zip doesn't work with well with binary data. Using CSS to "subscript" into the sprite is a better solution.

Except that the primary utility of zip is usually not its compression. It's the combining of multiple files into one "file". Basically what tar was invented for, but with actual universal support on every OS.

Re: JSZip: Create, read and edit .zip files with JavaScript

#20
post #15
post #10

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…

Some images formats already come with compression. Also, zip doesn't work with well with binary data. Using CSS to "subscript" into the sprite is a better solution.

It's not about saving bandwidth or space by compressing the images - it's about removing the step of combining your images into one big image then using coordinates inside of that image to find your original images.

Sure, you can build the spriting into your build process, but I don't know how to do that (I'm sure there are tools) and you can't exactly use normal css since the coordinates of your images may change within the sprite sheet.

Using the zip method saves you some of that headache/overhead with the tradeoff of having to package your images into a zip and unzip them on the client side.

Post reply on HN