Most browser word and trivia games start simple until real players hit edge cases you never anticipated on localhost.
When we shipped Minellion Games — an independent, free, zero-login browser Minecraft 1.21+ reverse-trivia game where rarer valid answers dig deeper from Y+64 Surface down to Y-64 Bedrock — we made one architectural constraint non-negotiable: zero runtime JS frameworks, zero iframes, and a single edge-served client bundle strictly under 100 KB.
Scaling the catalog from 538 → 829 Minecraft entities, hardening Global Leaderboards for public moderation, and testing inside a strict byte ceiling forced four concrete JavaScript lessons that generalize to any lightweight browser game.
1. Living Inside a Hard 100 KB Edge Script Limit (Zero Bundler, Zero Frameworks)
When your entire theme runtime script is validated server-side against a 100 KB ceiling (our current production script.js weighs in at 99,610 characters / 99,664 bytes), every kilobyte matters.
Instead of pulling in external UI libraries or validation dependencies, we kept all three game hubs — Daily Dig, Unlimited Practice, and Creeper Party (including its 5 zero-LLM local AI bot personas) — inside a single vanilla IIFE with tiny DOM helpers:
function ce(t, c, x) { var e = document.createElement(t); if (c) e.className = c; if (x != null) e.textContent = x; return e; } function on(e, t, f) { if (e) e.addEventListener(t, f); } Separating the static entity/prompt JSON catalog (829 entities across Mobs, Blocks, Items, Biomes, Enchantments, and Structures, also documented in the Minecraft 1.21+ Rarity Guide) from script.js means catalog expansions add zero bytes to the JavaScript bundle.
2. Scaling to 829 Entities Broke Single-Hit Alias Resolution
Once our catalog crossed 800+ Minecraft 1.21+ entities, shorthand aliases and plural stems started colliding across different prompt categories.
Consider what happens when a player types fossil or vex:
- If the prompt asks for a Minecraft Structure,
Nether Fossilis a valid answer — even thoughBone Blockis also tagged under blocks/fossils. - If a resolver maps normalized strings or aliases to a single entity and immediately returns
{ mismatch: cand }on the first candidate that failsmatchesPrompt(cand, prompt), whichever entity happened to be indexed first blocks the valid match in another category!
Our fix in resolveAnswer holds any prompt mismatch as mismatchCand instead of aborting early, inspecting every exact normalized bucket, alias bucket, and key hit across all query variants (singular, stripped articles, es/s/ies stems) — and even running bounded Levenshtein typo checks against valid entities before reporting a category mismatch:
function resolveAnswer(raw, data, prompt) { var vars = queryVariants(raw); if (!vars.length) return null; var mismatchCand = null; for (var vi = 0; vi < vars.length; vi++) { var qv = vars[vi]; var cands = [].concat( data.byNorm[qv] || [], data.aliases[qv] || [], data.byKey[qv] ? [data.byKey[qv]] : [] ); for (var ci = 0; ci < cands.length; ci++) { var cand = cands[ci]; if (matchesPrompt(cand, prompt)) return cand; if (!mismatchCand) mismatchCand = cand; } } // Pass 2: bounded Levenshtein recovery strictly over prompt-valid candidates var valid = data.entities.filter(function (e) { return matchesPrompt(e, prompt); }); for (var vi2 = 0; vi2 < vars.length; vi2++) { var q2 = vars[vi2]; var maxDist = q2.length >= 9 ? 2 : 1; var best = null, bestD = 99; for (var j = 0; j < valid.length; j++) { var d = lev(q2, valid[j]._n); if (d <= maxDist && d < bestD) { bestD = d; best = valid[j]; } } if (best) return best; } if (mismatchCand) return { mismatch: mismatchCand }; return null; } Notice why holding mismatchCand matters UX-wise too: if someone types Vex during an Armor Trim round, they don't get a vague "Unknown entity" rejection — they get clean feedback that Vex exists in the catalog (mob), whereas Vex Armor Trim (vex trim) belongs in the Trim round.
We extracted and open-sourced this exact multi-candidate bucket resolver pattern in v1.1.0 of sunrain113/minecraft-trivia-bot-engine (MIT License) alongside an interactive browser playground hosted on GitHub Pages.
3. Zero-False-Positive Moderation for Public Leaderboards (Watching Out for the Scunthorpe Trap)
Opening Global Leaderboards and shareable Creeper Party friend duel titles to zero-login visitors creates an immediate moderation requirement: you need to block URLs, Discord invite spam, zero-width character spoofs, and profanity without false-flagging normal Minecraft player handles.
A naive substring blocklist falls straight into classic traps:
- Blocking
hell,ass,tit, orcockas substrings falsely rejects legitimate gaming terms and Minecraft entities likeCompass,Grass,Nether,Wither, orWarden, and city/surname classics likeScunthorpe.
Our two-tier client guard combines:
- Invisible control / zero-width character normalization before length checks (
[\u0000-\u001F\u007F\u200B-\u200F\uFEFF]). - Domain / link / handle rejection (
https://,discord.gg,t.me/,play.example.gg). - Word-boundary token matching for short ambiguous strings (
\b...\b) paired with per-token stripped substring matching only for unambiguous slurs — plus an accessible inlineReportaction directly next to each public leaderboard entry so visitors can flag anything inappropriate with duplicate-report409idempotency.
Testing the open-source src/nickValidator.js module with Node's native node:test runner actually caught a real edge case immediately (ScunthorpeFan tripped a substring token), letting us move it into the word-bounded token regex while verifying safe Minecraft handles (Warden, Wither, Fossil, Compass, GrassBlock, RedstoneBot) pass cleanly.
4. Catching Variable Shadowing Under Tight Minification Budgets With node:vm
When you hand-trim helper names down to 2-character identifiers like on(el, ev, fn) and sa(el, k, v) to stay inside 99.6 KB, JavaScript var hoisting is a silent trap.
While compressing our theme bundle to keep headroom under 100 KB, hoisting a local var on inside a function inside the same IIFE shadowed the top-level function on(e, t, f) listener helper — breaking click handlers silently if on(...) was invoked anywhere inside that lexical scope. Because script.js runs directly in browsers without a TypeScript compiler step, static syntax checks (node --check) still exit 0 on valid shadowing!
Our pre-publish smoke suite now loads script.js inside node:vm with lightweight DOM stubs, executes initialization paths, dispatches simulated mode/filter clicks, and asserts resolver behavior (fossil, vex, vex trim) and zero-throw execution before deploying any site version. That 40-line node:vm smoke harness caught real runtime regressions twice faster than clicking around manually.
Try the Game or Inspect the MIT Engine
- Play Minellion Games (829 entities, free, zero login): https://minelliongames.com/
- Interactive Zero-LLM Bot & Resolver Sandbox (GitHub Pages): https://sunrain113.github.io/minecraft-trivia-bot-engine/
- Unlimited Practice Mode (Zen & Blitz): https://minelliongames.com/unlimited
- Creeper Party (5 Local AI Bots + Friend Duels): https://minelliongames.com/creeper-party
- Open-Source Vanilla ESM Engine (
v1.1.0, MIT): https://github.com/sunrain113/minecraft-trivia-bot-engine
(Disclosure: Independent fan-made Minecraft trivia web project; not affiliated with Mojang AB, Microsoft Corporation, or minellion.io.)