Get started with jszip CDN

(MIT OR GPL-3.0) licensed

JsZip is a popular library for creating and handling ZIP archives in the browser.

Tags:
  • zip
  • deflate
  • inflate

Stable version

Copied!

How to start using jszip CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with jszip CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
</head>
<body>
  <button id="download">Download ZIP</button>
  <script>
    document.getElementById('download').addEventListener('click', () => {
      const zip = new JSZip();
      const key = 'example';
      const content = 'Hello, World!';

      zip.file(key, content, { binaryString: true });

      zip.generateAsync({ type: 'blob' })
        .then((content) => {
          saveAs(content, 'example.zip');
        })
        .catch((err) => {
          console.error(err);
        });
    });

    function saveAs(blob, fileName) {
      const link = document.createElement('a');
      link.href = URL.createObjectURL(blob);
      link.download = fileName;
      link.click();
    }
  </script>
</body>
</html>
Copied!
Copied!

All versions