Để thực hiện tính năng này, cần sử dụng thêm 2 thư viện: jszip & FileSaver
https://github.com/Stuk/jszip
https://github.com/eligrey/FileSaver.js
Sử dụng:
var zip = new JSZip();
zip.file("Hello.txt", "Hello Worldn");
var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
zip.generateAsync({type:"blob"}).then(function(content) {
    // see FileSaver.js
    saveAs(content, "example.zip");
});
Để có thể dùng tính năng tải xuống trực tuyến sử dụng tùy chọn streamFiles
zip.generateAsync({ type: 'blob', streamFiles: true }).then(function (content)