Compressing the Wordle dictionary

submited by
Style Pass
2025-08-05 20:00:16

The popular word-guessing game Wordle is implemented using a 173KB JavaScript bundle, reduced to a 58KB transfer using Brotli compression. By efficiently compressing the dictionary, we can reduce the JavaScript bundle size by 36% to 111KB and the compressed transfer size by 26% to 43KB.

The Wordle JavaScript bundle contains a 10,657-word dictionary listing all of the five-letter words that Wordle will accept, accounting for 48% of the bundle size (83KB). The dictionary is stored as a simple JavaScript array:

The Brotli compression algorithm, like its predecessor gzip, can compress arbitrary text. The order of words matters when compressing most text, but in the case of an alphabetical list this information isn’t needed, as the words could have been stored in any order and later sorted into alphabetical order.

We can calculate how much information is required to represent the order of words. For a list of 10,657 unique words there are 10,657 × 10,656 × … × 3 × 2 × 1 possible permutations. Taking the binary logarithm of this number tells us that 127,219 bits are required to represent a permutation. This means we could potentially save over 15KB by only needing to represent one of the possible permutations.

Leave a Comment
Related Posts