Tiny JS games
I've been digging into how compact I could make Stasis games. And I once again was reminded about js 13k Games. In short, you have to have a whole web game fit into 13KB. That includes html, js, css, etc in a zip file. While it isn't as crazy as the 1KB demoscene javascript competitions, it is still a huge constraint. And my existing stasis games are more like 100 KB before images/audio. Small, but not that small.
I decided to try to design something pretty compact. I took lessons learned from building Stasis and made an even smaller representation of the logic. Just a tiny domain specific language (DSL). I did build an example game using AI (gpt-5.6-sol medium reasoning in codex). The core choices I made that were interesting:
- Game interopt is simple. There are just a few bindings between browser and game logic
- tri based. Almost all the graphics are just a series of triangles. 3 points defined and a color palette choice.
- No complex structure. The code is as simple as I could make it.
- Small compiler that optimises. It takes the logic and tries an output of html/js/wasm or html/js, zips it and finds the smallest example. Whichever wins.
Some observations.
- JS wins on size when there is not a lot of data defined because there's overhead with wasm that you have to overcome with later efficiencies.
- Defining with just triangles allows fun things, like converting to SVG for screenshots instead of PNG. And even exporting as SVG animations that are still compact. Even an animation like shown here is around 182KB, which isn't bad.
- A simple game, like a platformer with just a few characters can be tiny. Around 7 KB zipped. And more levels could be defined pretty efficiently.
- Sound is still a challenge. I can get the beeps of NES style games with pretty tiny file size changes, but don't know how to do better yet.
Here's an example of the "game" I tested. Yes, just a very basic proof of concept. This is an animated SVG that is clickable to play the actual demo.
Play the self-contained Shardbound game
(Animation: 182 KB uncompressed, Game 17 KB uncompressed)
Ben