var script document createElement script script type text javascript script src https cdnjs cloudflare com ajax libs jszip 3 6 0 jszip min js document head appendChild script window onload function console log JSZip var script document createElement script script type text javascript script src https cdnjs cloudflare com ajax libs jszip 3 6 0 jszip min js document head appendChild script window onload function var textBlock A test string var zip new JSZip zip file variables txt textBlock create a file and a folder zip file nested hello txt Hello World n or same as zip folder nested file hello txt Hello World n zip generateAsync type blob then function content console log zipfile contents String content write out the raw contents of what a zip file looks like async let r await content text console log zipfile contents r var script document createElement script script type text javascript script src https cdnjs cloudflare com ajax libs jszip 3 6 0 jszip min js document head appendChild script document body style height 50pt window onload function var textBlock A test string var zip new JSZip zip file variables txt textBlock create a file and a folder zip file nested hello txt Hello World n or same as zip folder nested file hello txt Hello World n zip generateAsync type blob then function content console log zipfile contents String content var a document createElement a document body appendChild a a innerHTML Click to Download Zip var file new Blob content type octet stream a href URL createObjectURL file a download Test zip a style font size 40pt var script document createElement script script type text javascript script src https cdnjs cloudflare com ajax libs jszip 3 6 0 jszip min js document head appendChild script window onload function var zip new JSZip zip file variables txt A zip file with txt and jpg image inside let nested zip folder nested put jpg inside a folder draw a pink triangle var canvas document createElement canvas canvas width 200 canvas height d 200 ctx canvas getContext 2d ctx beginPath ctx moveTo d 2 0 ctx lineTo d d ctx lineTo 0 d ctx closePath ctx fillStyle pink ctx fill convert canvas to jpg canvas toBlob canvasToBlob image jpeg 0 95 JPEG at 95 quality function canvasToBlob blob console log canvas blob blob nested file image jpg blob create zip file you can download zip generateAsync type blob then function content console log zipfile contents String content var a document createElement a document body appendChild a a innerHTML Click to Download Zip var file new Blob content type octet stream a href URL createObjectURL file a download Test zip a style font weight 900 end generateAsync end canvasToBlob end onload
ent body appendChild a a innerHTML Click to Download Zip var file new Blob content type octet stream a href URL createObjectURL file a download Test zip a style font size 40pt var script document createElement script script type text javascript script src https cdnjs cloudflare com ajax libs jszip 3 6 0 jszip min js document head appendChild script window onload function var zip new JSZip zip file variables txt A zip file with txt and jpg image inside let nested zip folder nested put jpg inside a folder draw a pink triangle var canvas document createElement canvas canvas width 200 canvas height d 200 ctx canvas getContext 2d ctx beginPath ctx moveTo d 2 0 ctx lineTo d d ctx lineTo 0 d ctx closePath ctx fillStyle pink ctx fill convert canvas to jpg canvas toBlob canvasToBlob image jpeg 0 95 JPEG at 95 quality function canvasToBlob blob console log canvas blob blob nested file image jpg blob create zip file you can download zip generateAsync type blob then function content console log zipfile contents String content var a document createElement a document body appendChild a a innerHTML Click to Download Zip var file new Blob content type octet stream a href URL createObjectURL file a download Test zip a style font weight 900 end generateAsync end canvasToBlob end onload