When building a browser word game that runs 100% client-side with zero backend API round trips, dictionary size quickly becomes the bottleneck between "instant first paint" and "why did my completely normal English word get rejected?"
While upgrading Word Chain and Word Ladder Game, we ran headfirst into that exact tension:
- Our 4-letter Word Ladder board validates moves against 3,920 four-letter words from the public-domain ENABLE2K lexicon.
- Our tail-to-head Word Chain (English Shiritori) mode originally shipped with only ~4,000 words — which meant players typing
PLANET,ELEPHANT, orGARDENgot rejected despite the rules promising 4-to-8 letter words. - Including all 75,728 verified 5-to-8 letter ENABLE2K words raw as a JSON array weighed ~600 KB uncompressed, which would bloat the main bundle if not compressed and route-split cleanly.
Here is the exact zero-dependency prefix-delta compression we used to pack all 75,728 5–8 letter words into 228 KB raw (~93 KB gzipped), decode them in under 12 ms on page hydration, and pair them with an O(L) wildcard-bucket BFS solver.
1. Prefix-Delta Encoding for Sorted Word Lists (~62% Smaller Before Gzip)
Because ENABLE2K is strictly ASCII-sorted (aahed, aahing, aalii, aaliis, ...), consecutive words almost always share a long prefix. Since every word in our 5–8 letter tier has length ≤ 8, the shared prefix length between two adjacent words is always a single digit 0–7!
Encoding each entry as <sharedPrefixDigit><suffix> requires no delimiter characters at all because digits (0–7, char codes 48–55) never appear in lowercase a–z English words (97–122):
// Encoder (build-time, deterministic) export function encodePrefixList(sortedWords) { let prev = ''; let out = ''; for (const word of sortedWords) { let shared = 0; const maxShare = Math.min(7, prev.length, word.length); while (shared < maxShare && prev[shared] === word[shared]) { shared += 1; } out += String(shared) + word.slice(shared); prev = word; } return out; } And the browser decoder is 20 lines of pure integer-charCode scanning (zero regexes, zero string-splitting allocations):
// Decoder (client-side, <12ms for 75,728 words) export function decodePrefixList(packed) { const words = new Set(); let prev = ''; let i = 0; const n = packed.length; while (i < n) { const code = packed.charCodeAt(i); if (code >= 48 && code <= 55) { const share = code - 48; i += 1; let j = i; while (j < n && packed.charCodeAt(j) >= 97) j += 1; prev = prev.slice(0, share) + packed.slice(i, j); words.add(prev); i = j; } else { i += 1; } } return words; } Results on real ENABLE2K data:
-
75,7285–8 letter words +3,9204-letter words =79,648total verified words - Raw encoded payload:
228,731bytes (down from ~610 KB JSON) - Over-the-wire gzip:
~93 KB, route-split exclusively to/word-chainso the main/route never downloads a single extra byte.
We open-sourced the exact encoder, decoder, letter-degree analyzer, and CLI under MIT / CC0 at github.com/soler-yang/enable2k-word-chain-graph.
2. O(L) Wildcard-Bucket BFS for Shortest Word Ladders & Dual-Tier Hints
Finding the shortest Word Ladder (Lewis Carroll's 1877 Doublets) between two 4-letter words naively compares every word against every other word (O(N²)). Instead, indexing each word into 4 wildcard buckets (COLD → *OLD, C*LD, CO*D, COL*) builds the full adjacency structure of all 3,920 four-letter words in milliseconds:
function buildBuckets(words) { const buckets = new Map(); for (const w of words) { for (let i = 0; i < w.length; i += 1) { const key = w.slice(0, i) + '*' + w.slice(i + 1); if (!buckets.has(key)) buckets.set(key, []); buckets.get(key).push(w); } } return buckets; } One surprising player-experience insight from running BFS on real puzzles: the mathematically shortest path isn't always the most fun hint. For Lewis Carroll's famous 1879 pair HEAD → TAIL:
- Full 3,920-word ENABLE2K BFS (4 moves):
HEAD → HEAL → HEIL → HAIL → TAIL - Everyday 698-word Familiar Pool BFS (5 moves):
HEAD → HEAL → TEAL → TELL → TALL → TAIL
So our game separates validation (accepting all 3,920 words) from hints (searching our 698-word everyday pool first), and our 4-Letter Word Ladder Solver & Blind Custom Challenge Builder renders both paths side by side. The standalone BFS library is open-sourced at github.com/soler-yang/word-ladder-bfs-solver.
3. Surprising Graph Findings in ENABLE2K
Analyzing both word graphs programmatically turned up several fun facts that became our word-graph strategy guides:
- 64 "Aloof" Degree-0 Four-Letter Words: Just like Donald Knuth found in The Stanford GraphBase (1993), 64 valid four-letter words (
AQUA,AWOL,EXAM,LYNX, etc.) have zero one-letter neighbors — documented in our word list connectivity breakdown. - X & Z Bottlenecks: Across 3,920 four-letter words, only
22end in-X,20end in-Z, and literally one starts withX(XYST) — see our 4-letter X & Z graph study. - Word Chain Trap Letters: In the 79,648-word 4–8 letter Shiritori graph, ending a word in
Xleaves opponents with fewer than 100 valid replies compared to 8,000+ replies forS— analyzed in Word Chain Examples & Trap Strategy.
4. Zero-Asset Web Audio & Print-Ready CC0 Classroom Worksheets
Two small browser-native touches that improved player engagement with near-zero bundle weight:
- Procedural Web Audio UI feedback (~25 lines): Synthesizing short triangle/sine key-click and chord chimes with
AudioContextremoves all.mp3/.wavnetwork requests while keeping mute state inlocalStorage. - CSS
@media printClassroom Handouts: Because teachers frequently ask for printable Doublets sheets, we added a seeded CC0 Printable Word Ladder Worksheet Generator that renders clean write-in letter grids plus an automatic Page-2 teacher answer key withpage-break-before: always— zero server-side PDF dependencies.
If you're building browser word puzzles or teaching graph algorithms, feel free to grab the open-source 79k Word Chain Graph CLI or test custom pairs directly in the Word Ladder Solver.
