All the features of zip files are not supported. Classic zip files will work but encrypted zip, multi-volume, etc are not supported and the loadAsync() method will return a failed promise.
async method and the
hold the full result in memory but doesn’t freeze the browser. If the result
is too big, and if you can’t use the
nodeStream method or the
you need to use the underlying
handle the result chunk by chunk and
resume() to handle the
If you’re having performance issues, please consider the following :
type:"uint8array"(or blob, arraybuffer, nodebuffer).
Note about compression : When reading a file, JSZip will store the content without decompressing it. When generating a compressed file, JSZip will reuse if possible the compressed content :
generatewith the DEFLATE compression, JSZip won’t call the compression algorithms (same with STORE everywhere.)
generatewith the STORE compression, JSZip will have to decompress everything.
On IE <=9, typed arrays are not supported and the compression algorithm will fallback on arrays. In that case, JSZip needs to convert the binary string into an array, DEFLATE it and convert the result into a binary string. You don’t want that to happen.
Reading and generating a zip file won’t give you back the same file. Some data are discarded (file metadata) and other are added (subfolders).
JSZip only supports UTF-8 natively. A zip file doesn’t contain the name of the encoding used, you need to know it before doing anything.
If the name of a file inside the zip is encoded with UTF-8 then JSZip can detect it (Language encoding flag, Unicode Path Extra Field). If not, JSZip can’t detect the encoding used and will generate Mojibake. You can use the encodeFileName option and the decodeFileName option to encode/decode using a custom encoding.
async("string") method uses UTF-8 to decode the content. If you have a text in
a different encoding, you can get the bytes array with
decode it with a lib (iconv, iconv-lite, etc) on your side.
To save a text using a non-UTF-8 encoding, do the same : encode it into a
Uint8Array before adding it to JSZip.