Download the generated zip file

The FileSaver API

Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).

"use strict";

var zip = new JSZip();
zip.file("Hello.txt", "Hello world\n");

jQuery("#blob").on("click", function () {
    zip.generateAsync({type:"blob"}).then(function (blob) { // 1) generate the zip file
        saveAs(blob, "hello.zip");                          // 2) trigger the download
    }, function (err) {
        jQuery("#blob").text(err);
    });
});
<p>Works on firefox, chrome , opera &gt;= 15 and IE &gt;= 10 (but NOT in compatibility view).</p>
<button id="blob" class="btn btn-primary">click to download</button>

The data URL

Does not work in IE, has restrictions on the length.

"use strict";

var zip = new JSZip();
zip.file("Hello.txt", "Hello world\n");

jQuery("#data_uri").on("click", function () {
    zip.generateAsync({type:"base64"}).then(function (base64) {
        window.location = "data:application/zip;base64," + base64;
    }, function (err) {
        jQuery("#data_uri").text(err);
    });
});
<p>Does not work in IE, has restrictions on the length.</p>
<button id="data_uri" class="btn btn-primary">click to download</button>