Why a browser game can start in seconds

Under the hood · what actually happens while you wait

When you click play on a web game, nothing gets installed. The whole game has to travel across the network and be running a moment later. Four things happen in that gap, and every one of them costs time.

First the browser downloads the files. Then it parses them, which means reading the text of the program and working out what it says. Then it compiles that into instructions your processor can actually run. Only after all of that does the game get to draw its first frame.

Each of those steps gets slower as the game gets bigger. A larger download takes longer to fetch, longer to read, and longer to compile. So the single most useful thing a web game can be is small.

The part we never have to send you

A game built in a large engine has to ship the engine along with it. Before anything happens on screen, the browser pulls down a general-purpose renderer, a physics system, an audio system, a scene manager and a scripting layer, starts all of it up, and only then loads the actual game on top. That is a lot of machinery to move before anyone gets to press a key.

Our web games skip that, because the browser already is the engine. It has a JavaScript engine built in. It has a 2D drawing surface built in. It has WebGL, which is direct access to the same graphics hardware a desktop game uses, built in. It has an audio system that can build sound out of pure maths. None of that gets downloaded. It has been sitting on your machine since you installed the browser.

A game written straight against those built-in pieces therefore has nothing to boot. Our first line of code runs, and the renderer it wants is already warm.

Art that is code instead of files

The other half of most downloads is the art: textures, models, music, sound effects. In almost every game these weigh far more than the program itself.

Deepwick takes the opposite route as far as it will go. It contains no image files and no audio files whatsoever. Every wall, every ember and every flicker of the flame is drawn from shapes and gradients while you play, and every sound is generated by the browser's audio system at the moment it is heard. The finished game, compressed, is around twenty kilobytes. That is smaller than a single photograph on most web pages.

Not every game gets to do that. Void Daggers needs a full 3D arena. AISLE 7 needs a supermarket full of models. Those are heavier, and we plan for it. But the instinct carries across all of them: if a thing can be described in code more cheaply than it can be stored in a file, we describe it in code.

Build only what the first frame needs

There is one more saving available, and it comes from refusing to confuse "the game is ready" with "everything in the game exists".

Moon Miner does not generate its whole Moon before letting you dig. It builds the first slice of rock, thirty two rows deep, and starts. Everything below that is built in the spare moments between frames, always running ahead of your drill, so you never wait for it and never notice it happening. By the time you have chewed through the top layer, the next one has quietly finished being invented.

That principle generalises. A loading screen only has to produce the first frame. Anything the first frame does not need can be made later, while you are already playing.

How the budget shapes the game

Give yourself a small size budget and it stops being a restriction on the art, and starts being a design brief. Generated worlds are no longer a clever flourish, they are simply the cheapest way to have a big world. Sound built from waveforms is no longer a compromise, it is how you get a hundred variations of a footstep out of nothing.

Most of what these articles describe grew out of that pressure. The Moon is calculated rather than stored because storing it would cost a download. Deepwick's caves are calculated for the same reason. Void Daggers builds its surfaces while it runs instead of shipping textures. The wait you do not have at the start is paid for by decisions made deep inside each game.

▶ Play a game in your browser