CompressionStream
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2023.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The CompressionStream interface of the Compression Streams API compresses a stream of data. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.
Constructor
CompressionStream()-
Creates a new
CompressionStream.
Instance properties
CompressionStream.readable-
Returns the
ReadableStreaminstance controlled by this object. CompressionStream.writable-
Returns the
WritableStreaminstance controlled by this object.
Examples
In this example a stream is compressed using gzip compression.
js
const compressedReadableStream = inputReadableStream.pipeThrough(
new CompressionStream("gzip"),
);
Specifications
| Specification |
|---|
| Compression # compression-stream |