The Compression Streams API is for compressing and decompressing streams of information utilizing nan gzip aliases deflate (or deflate-raw) formats.
Using nan built-in compression of nan Compression Streams API, JavaScript applications do not request to see a compression library, making nan download size of nan exertion smaller. This useful API is now supported crossed each browsers.
Compressing data
The pursuing snippet shows really to compress data:
const readableStream = await fetch('lorem.txt').then( (response) => response.body ); const compressedReadableStream = readableStream.pipeThrough( caller CompressionStream('gzip') );Decompressing data
To decompress, tube a compressed watercourse done nan decompression stream.
const decompressedReadableStream = compressedReadableStream.pipeThrough( caller DecompressionStream('gzip') );Browser compatibility
Demo
Part of nan Newly interoperable series
Except arsenic different noted, nan contented of this page is licensed nether nan Creative Commons Attribution 4.0 License, and codification samples are licensed nether nan Apache 2.0 License. For details, spot nan Google Developers Site Policies. Java is simply a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-02 UTC.
[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing nan accusation I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too analyzable / excessively galore steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / codification issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]