keyboard_backspace wifi_off

Compression Streams API

This feature is not (yet) supported on your device

The Compression Streams API allows you to compress and decompress streams of data, including files.

Demo

Select one or more files to compress using the "Choose file(s)" button. The compressed file can be downloaded below.

attach_file

You can find the FileCompressor component on GitHub.

const fileField = document.querySelector('#file'); const downloadLink = document.querySelector('#download-link'); fileField.addEventListener('change', async () => { const files = [...fileField.files]; try { const fileCompressor = new FileCompressor(); const blob = await fileCompressor.compress(files); const url = URL.createObjectURL(blob); downloadLink.href = url; downloadLink.textContent = 'Download compressed-files.zip'; } catch(e) { console.log('error', e); } });

Documentation

Compression Streams API on MDN

Browser support

Compression Streams API on caniuse.com

What PWA Can Do Today A showcase of what is possible with Progressive Web Apps today