# Dictionary compression for web data: how it works and how to use it with Node.js

DevFeed: [Dictionary compression for web data: how it works and how to use it with Node.js](<https://devfeed.tech/articles/dictionary-compression-is-finally-here-and-it-s-ridiculously-good-19056.md>)

Original publisher: [Read original article](<https://httptoolkit.com/blog/dictionary-compression-performance-zstd-brotli/>)

Author: HTTP Toolkit; Tim Perry

Published: 2026-02-23T13:00:00Z

Content type: tutorial

Language: en

Sources: [HTTP Toolkit](<https://devfeed.tech/sources/http-toolkit.md>)

Topics: [Compression](<https://devfeed.tech/topics/compression.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Node.js](<https://devfeed.tech/topics/node-js.md>), [API](<https://devfeed.tech/topics/api.md>), [WebAssembly](<https://devfeed.tech/topics/web-assembly.md>), [JSON](<https://devfeed.tech/topics/json.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [api](<https://devfeed.tech/tags/api.md>), [browser](<https://devfeed.tech/tags/browser.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [compression](<https://devfeed.tech/tags/compression.md>), [data](<https://devfeed.tech/tags/data.md>), [http](<https://devfeed.tech/tags/http.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [json](<https://devfeed.tech/tags/json.md>), [node-js](<https://devfeed.tech/tags/node-js.md>), [performance](<https://devfeed.tech/tags/performance.md>), [standards](<https://devfeed.tech/tags/standards.md>), [webassembly](<https://devfeed.tech/tags/webassembly.md>)

## AI overview

This tutorial explains dictionary compression, where the compressor and decompressor share known data so compressed output can reference it directly. It discusses using previous responses or custom dictionaries to reduce the size of JavaScript bundles, WebAssembly files, and structured API responses, and demonstrates the technique with Node.js.

## Source excerpt

Dictionary compression could completely change how applications send data over the web. It's recently gained broad support, and offers absurd real-world traffic reductions: initial testing shows YouTube JS download size for returning desktop users shrinking up to 90% (!!!) compared to existing best-practice compression, while the Google search results HTML (arguably the most optimized content on the internet) shrinks nearly 50%. This works by initializing the (de)compression algorithm with a dictionary of data known in advance to both compressor & decompressor, so that the compressed data can just be references to that directly ("insert bytes 1 - 10,000 from the dictionary") without having to include the original data at all. This is applicable in a surprising number of scenarios, because most data we send (especially on the web) isn't completely novel or unpredictable. Today's JavaScript bundle shares 99% of its content with yesterday's JavaScript bundle - if the browser already has the old one, using that as a dictionary means you can compress down to (approximately) just the differences. This can work either using a previous response as the dictionary for the next response, or using an explicit custom dictionary; for many kinds of dynamic response, you do know large chunks of the data in advance, like all the keys in your API's JSON response, and many common values that might be included, and you can generate & preload a dictionary defining exactly this to efficiently cover those. In either case, this can drastically shrink JS bundles, WebAssembly files, known-structure API responses, or many other kinds of incrementally updated & diffable content - a lot of the worst offenders for bandwidth usage that have become very common on the modern web. This is now widely usable, safe to deploy without compatibility concerns, and surprisingly easy to set up. Here's a quick low-level demo for Node.js (v24.6+ or v22.19+) so you can play with the raw compression directly for