跪拜 Guibai
← All articles
Frontend

A 126-Card Kids Recognition Game Ships as One 2.3MB HTML File, No Build Step Required

By 墨林陌 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Single-file, no-build apps are still a real deployment option for small clients: this one carries 126 images and interactive games in 2.3MB, works offline, and survives static publishing by putting every asset path in an <img> tag. The pattern also shows what AI-generated assets can and cannot handle without runtime corrections.

Summary

Eight prompt-driven iterations turned an initial two-word brief, "educational game", into a 126-card recognition toy for children aged 3 to 6. The deliverable is one HTML file plus an assets folder: 106KB of inlined CSS/JS and 2.2MB of compressed JPEG cards, with no framework and no npm step. The game's three modes cover identifying cards by category, tap-to-connect matching, and memory flip with 4/6/8/10 pairs.

Requirements were nailed down before layout: near-zero literacy means sparse text and sound-first interaction; parents vetoed countdowns, leaderboards, points, and combo effects. 80 physical-object cards use AI-generated art at 512px/JPEG q85, while 46 number, letter, and shape cards are drawn as inline SVG at runtime, so AI can't miscount dots and the vector set adds zero bytes.

Key mechanics worth copying include a hidden display:none image library whose src attributes are visible to static publishing scanners, an SVG dash-offset animation for draw-in connect lines, state that stores actual dealt pair counts to keep progress bars solvable, and a Web Audio layer that synthesizes every sound and starts muted under a user-gesture gate. The whole game works offline on a phone or tablet, and deployment reuses one app id so a family link stays stable.

Takeaways
— A two-character initial prompt, "educational game", grew into an eight-iteration project; every version edited the same single HTML file and filename.
— The final size is 2.3MB total: 106KB of HTML plus 2.2MB of 80 JPEG illustrations compressed to 512px at quality 85, all cached locally after first open.
— The card pool is 126: 80 AI-illustrated cards in 8 categories, 10 number cards, 26 letter cards, and 10 color/shape/size cards; the 46 vector cards add zero bytes.
— Three game modes: 认一认 taps a card and reads its information, 连一连 connects one card on the left to a matching card on the right, and 翻翻乐 is memory matching with 4, 6, 8, or 10 pairs.
— There are no countdowns, leaderboards, scores, or combo effects; the progress bar shows only a count like "found 3/6 pairs" and never turns red.
— All illustration image paths live in a hidden display:none img library and are cloned at runtime, because static publishing scanners only detect paths in src attributes or CSS url() values.
— Concept cards are rendered as inline SVG on the fly: numbers get code-calculated dots, letters pair uppercase and lowercase, colors are pure swatches, and size cards show a large and small circle in one frame.
— Connect-game lines are SVG cubic Bézier paths animated from full stroke-dashoffset to zero; only newly created lines get the animation via a fresh flag.
— The code writes the actual number of pairs dealt to state.pairs, and all progress and completion text reads from it, so a category with fewer cards than a difficulty tier still produces a solvable game.
— All sound effects are synthesized through Web Audio OscillatorNode with no audio files: flip 620Hz, match 660→880→1120, win 523→659→784→1046; audio starts muted, requires a user gesture, exposes a role=switch toggle, volume 0.32, and remembers state in localStorage.
— Access logs stay in localStorage, cap at 60 entries, and writes are wrapped in try/catch because private mode throws; true cross-device visit counts are left out of scope.
Conclusions

The three clarifying questions asked after the first prompt did more design work than any model capability: a four-character brief became a concrete product only after audience, form, and target skill were pinned down.

Moving concept cards to inline SVG is a sound judgment call: AI art can put six or eight stars next to a 7, and a red apple teaches the color less clearly than a pure swatch, while vector cards cost zero bytes and cannot fail the count.

A static publishing pipeline that only scans src and url() imposes a real trade-off: every image must be pulled into the initial load block, and the resulting 2.2MB is the price of a deployment that never needs a server.

Traffic analytics stay off the table: the log feature only writes to localStorage because a true open count would require a backend, and that would break the static, offline deliverable.

Concepts & terms
Single-file HTML app
A web app with all CSS and JavaScript inlined into one .html file, using relative asset paths; it opens by double-click and deploys without a build step or package manager.
Hidden image gallery
A display:none container holding every <img> tag for all assets; the app clones the needed node at runtime. This keeps asset paths visible to static scanners in the src attribute and preloads files into cache.
stroke-dashoffset animation
A technique where a path's stroke-dasharray is set to the total path length and dashoffset animates to 0, making a line appear to draw itself from start to end.
prefers-reduced-motion
A CSS media feature, also queryable in JS, that tells an app the user wants less animation; the game jumps straight to final states when it is honored.
From the discussion

The decision to drop the countdown timer earns strong praise as a child-friendly move; pressure and rushing lead to tears for young kids with unsteady hands. The single-file HTML format is also valued for its portability and ease of use for parents, and the overall simplicity is seen as thoughtful design. A side point suggests using AI tool directories for inspiration on similar utilities.

— Removing the countdown is essential: timers create anxiety and tears in 3–4 year olds whose motor skills are still developing.
— Single-file HTML is parent-friendly for its portability and instant usability.
— Simplicity—click and play—reflects careful design thinking.
— One contributor recommends AI tool navigation sites for finding inspiration on similar tools.
Featured comments
组合搭配函数

Removing the countdown is crucial. Adding a countdown to a game for 3–4 year olds just creates anxiety; their hands aren't steady yet, and being rushed makes them cry. This detail shows real understanding of parenting, it's touching.

咬代码的兽

Very cleverly done. A single-file HTML is super convenient for parents—just save it and it works. For inspiration on such small tools, I usually browse AI tool directories like ai345, which sort by scenario for quick discovery and update frequently with new tools.

AloneBlack

The greatest simplicity—click to play. It's clear a lot of thought went into this.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗