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 inWeb Workers.
TheCompressionStream interface of theCompression Streams API compresses a stream of data. It implements the same shape as aTransformStream, allowing it to be used inReadableStream.pipeThrough() and similar methods.
In this article
Constructor
CompressionStream()Creates a new
CompressionStream.
Instance properties
CompressionStream.readableReturns the
ReadableStreaminstance controlled by this object.CompressionStream.writableReturns 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> |