Compression Streams API reaches cross-browser milestone
Web developers can now use native gzip, deflate, and deflate-raw compression and decompression in every major browser. The Compression Streams API, previously limited by inconsistent support, is now available in Chrome 80+, Firefox 80+, Safari 16.4+, and Edge 80+.
Because the compression is built into the platform, JavaScript apps no longer need to ship third-party compression libraries. That eliminates a dependency and trims the application's download size.
Compressing a stream
Pipe data through a new CompressionStream instance, specifying the format as "gzip", "deflate", or "deflate-raw".
const readableStream = await fetch('lorem.txt').then(
(response) => response.body
);
const compressedReadableStream = readableStream.pipeThrough(
new CompressionStream('gzip')
);
Decompressing a stream
Reverse the process by piping a compressed stream through a DecompressionStream with the matching format argument.
const decompressedReadableStream = compressedReadableStream.pipeThrough(
new DecompressionStream('gzip')
);



