---
title: Snake
url: 'https://niklas-stephan.de/en/zoo/snake'
markdown: 'https://niklas-stephan.de/en/zoo/snake.md'
lang: en
date: '2026-11-26'
description: 'A deliberately small project: the whole game is index.html, style.css and game.js — no framework, no bundler, no dependencies, MIT-licensed. It started as a question of how little code a complete, pleasant snake game needs, and the answer was about 200 lines. Still in there: a 24×24 grid with class…'
---

HTML · Canvas

# Snake

The classic snake game for the browser — one canvas, three files, no dependencies and no build step. Steer with keys or swipes, high score stays on your device.

2026-11-26

A deliberately small project: the whole game is `index.html`, `style.css` and `game.js` — no framework, no bundler, no dependencies, MIT-licensed. It started as a question of how little code a complete, pleasant snake game needs, and the answer was about 200 lines.

Still in there: a 24×24 grid with classic wall collisions, a speed ramp from 140 to 65 ms per step, buffered turn input so quick double-taps can't reverse the snake into itself, touch swipes, light and dark mode, a DPI-sharp canvas, auto-pause when the tab hides, and a high score that lives in `localStorage` — on your device, not on a server.

 [ Repository](https://github.com/handtrixx/snake) [ Play](https://handtrixx.github.io/snake/)

---

## Navigation

- Parent: [Zoo](https://niklas-stephan.de/en/zoo.md)
- Next: [Grava the HUD](https://niklas-stephan.de/en/zoo/grava-the-hud.md)
