Brendan Eich sketched JavaScript in ten days at Netscape in May 1995 (verified against en.wikipedia.org/wiki/JavaScript on 2026-08-16), and thirty-one years later every question of the form “how to make a game in javascript” still reduces to the same three primitives: an HTML <canvas> element, a request-animation-frame loop that reads state and draws pixels, and a small pile of keyboard and mouse event handlers. The 2026 stack has not changed those primitives, but everything above them — the sprite art, the music, the SFX, and even the tick loop scaffolding — is now a one-prompt problem instead of a one-weekend problem. That means WizardGenie to scaffold the update-and-draw loop, the input handlers, and the JSON save-load pair, Sorceress AI Image Gen for the sprite art and background layers, Music Gen for the loopable soundtrack, and SFX Gen for the ten-plus stingers that separate a demo from a game. This guide is the honest end-to-end for how to make a game in javascript that ships in a browser tab in a weekend in 2026, under five dollars in Sorceress credits.
What “how to make a game in javascript” actually means in 2026
The query “how to make a game in javascript” hides three very different builds. Some searchers want a vanilla-JS Canvas game — a single HTML file, one <canvas>, a couple hundred lines of ES modules, no build step, no framework. Some searchers want a Phaser or three.js game — a proper game framework, ES modules bundled by Vite, a scene graph, a physics engine, and a real production-ready deploy. And some searchers want a Node-plus-browser game — a small server keeping shared state (multiplayer, leaderboards) with JavaScript on both sides. This guide targets the shared 2026 core of all three because the mental model is identical: JavaScript reads player input, runs an update function on world state, and paints the result to a canvas at 60 Hz.
Four things make JavaScript still the correct answer for a hobby game in 2026. First, the browser is the delivery target: no installer, no store review, no cross-platform build matrix, just a URL. Second, Canvas 2D and WebGL2 are stable and fast per the MDN Canvas API reference verified 2026-08-16 — a modern browser draws thousands of sprites per frame without breaking a sweat. Third, requestAnimationFrame gives you a v-sync-matched 60 Hz callback for free per the MDN requestAnimationFrame reference verified 2026-08-16, so you never write the render clock yourself. Fourth, ES module syntax and modern JavaScript are a real language now — classes, generators, private fields, top-level await, structured clone — and a coding agent writes idiomatic modern JS by default. Nothing about writing a game in JavaScript in 2026 requires a compile step or a build tool if you keep the scope tight.
The JavaScript game loop in thirty lines
Every game in JavaScript is the same skeleton. Read input, update world state, draw the world to the canvas, and yield to the browser until the next frame. In modern JS the whole loop fits in about thirty lines and never touches the DOM after boot except through the single canvas element. The five moving parts are: an input buffer that keyboard and mouse listeners push events into, an update function that reads the buffer plus current world state and mutates world state, a draw function that reads world state and paints pixels to the canvas, a request-animation-frame boot that ties update and draw together, and a delta-time accumulator that keeps the update rate independent of the render rate so a 144 Hz monitor and a 30 Hz mobile tab both feel the same.
The critical discipline is the same one that keeps a simulation game or a platformer honest: the update function never draws pixels and the draw function never mutates world state. That single rule means your game survives a slow tab, a hot reload, or a save-and-restore without any hidden coupling. Concretely: keep a world object as a plain JS record (player position, enemy array, tile grid, score counter), a keys record for currently-held keys, and a small input array for one-shot events (mouse clicks, key-down transitions). The update function consumes input and reads keys; the draw function only reads world. Everything else — the pause menu, the save-load system via the browser's localStorage API verified 2026-08-16, the game-over screen, the audio playback — is layered on top of these five pieces.
Pick your engine for how to make a game in javascript: vanilla Canvas, Phaser 4, or WizardGenie
Three good targets in 2026, each with a very different trade-off. Vanilla HTML plus a single Canvas element plus ES modules is the right pick when the game is a small arcade build (breakout, snake, a shooter, a match-3) and you want zero build steps. A working vanilla JS game engine is roughly 300 lines of JavaScript: the boot function that creates the canvas and 2D context, the input listener pair, the update-and-draw loop, the sprite atlas that maps IDs to positions in a single PNG, and the save-load pair. You get pixel-level control, zero framework overhead, and a total build size under 40 KB before assets. This is the honest default for a first arcade or puzzle build.
Phaser 4.2.1 “Giedi” (released 9 July 2026, verified against phaser.io/download/stable on 2026-08-16) is the honest default when the game needs a real scene graph, a proper camera, a tween system, tilemap loading from Tiled, physics for a platformer or a top-down shooter, or an asset loader that streams sprite sheets and audio in parallel. Phaser is a single JavaScript file, roughly 900 KB minified, and pulls in via a script tag or an npm install. It ships Scene management, an asset loader, tween animations, a Tilemap layer, an arcade physics engine, and audio playback in one library. Any game bigger than a single-screen arcade build is easier in Phaser.
WizardGenie is not a separate rendering engine — it scaffolds whichever of the two above you pick from a single natural-language prompt. WizardGenie is the Sorceress game-native coding agent. It ships as both a Windows desktop app (installer with auto-update, available to Early Access supporters and above) and a no-install web build at the same URL. Its coding-model lineup (verified 2026-08-16 in src/app/_home-v2/_data/tools.ts lines 766 through 775) covers Claude Opus 4.7, Claude Sonnet 4.6, GPT-5.5, Gemini 3.1 Pro, DeepSeek V4 Pro, Kimi K2.5, Grok 4.2, and MiniMax M2.7. For a first vanilla-JS Canvas game with a single-file scope, any model in the lineup writes the whole skeleton in under two minutes. If you want to run cheap on a long session, pair a frontier planner (Claude Opus 4.7 or GPT-5.5) with a budget executor (DeepSeek V4 Pro or Kimi K2.5) — the planner writes the world-state schema and the update pseudo-code, the executor types the code. That pairing runs at roughly one-fifth the cost of a single-frontier session.