Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Compression Streams API

Compression Streams API

Baseline 2023
Newly available

Since ⁨May 2023⁩, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available inWeb Workers.

TheCompression Streams API provides a JavaScript API for compressing and decompressing streams of data using the gzip or deflate formats.

Built in compression means that JavaScript applications will not need to include a compression library, which makes the download size of the application smaller.

The Fetch API'sResponse can be used to convert streams to:

Interfaces

CompressionStream

Compresses a stream of data.

DecompressionStream

Decompresses a stream of data.

Examples

In this example a stream is compressed using gzip compression.

js
const compressedReadableStream = inputReadableStream.pipeThrough(  new CompressionStream("gzip"),);

In the following example a function decompresses a blob using gzip.

js
async function DecompressBlob(blob) {  const ds = new DecompressionStream("gzip");  const decompressedStream = blob.stream().pipeThrough(ds);  return await new Response(decompressedStream).blob();}

Specifications

Specification
Compression
# compression-stream

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp