Live data from Hacker News

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

stuk.github.io

31–40 of 57 posts

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

#31
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.

There is definitely work towards this. This spec was recently released and has some potential: https://github.com/w3ctag/packaging-on-the-web

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

#32
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…

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.

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

#33
post #26

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.

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.

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

#34

Earlier quoted context omitted.

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.

seems like multipart http responses may be pretty close to what we want

a multipart http response saves what kind of file?

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

#35
post #20
post #15

Earlier quoted context omitted.

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

You can embed the images in the CSS as data: URIs, preferably automatically as part of the build process, and get the best of both worlds.

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

#38
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…

So is the point to simplify the process or something else?

CSS Sprites are very easy to make and use. You just need to set the right coordinates for the background-image.

On the other hand, running a complicated JS library and building an infrastructure to extract these images seems like an overkill for something that CSS sprites can do so easily.

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

#39
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…

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.

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?
Post reply on HN