Making an HTML5 game run on a desktop is easy. Making it feel good on a phone, in a mobile browser, with no install, is where most of the work hides. This is the checklist I use for the browser games on InstantGames.in, which all run on phone, tablet and desktop.
1. Touch input, done properly
Use Pointer Events where you can. They unify mouse, touch and pen, and give each finger an id, which is what makes multi-touch work.
// simplified sketch
const pointers = new Map();
canvas.addEventListener("pointerdown", e => pointers.set(e.pointerId, [{x: e.offsetX, y: e.offsetY}]));
canvas.addEventListener("pointermove", e => pointers.get(e.pointerId)?.push({x: e.offsetX, y: e.offsetY}));
canvas.addEventListener("pointerup", e => pointers.delete(e.pointerId));
canvas.style.touchAction = "none"; // stop the browser scrolling or zooming on your game
Two details matter:
-
touch-action: noneon the canvas, or the page will scroll during a swipe. - Track each pointer separately so two fingers can slice at the same time.
2. Swipes need segment tests
On a phone, a fast swipe can jump many pixels between events. If you test only the points you receive, a blade can pass straight through an object. Test the line segment between consecutive points against your targets.
3. Size the canvas for the screen
Handle device pixel ratio so things look crisp, but cap it to avoid huge canvases on high-density screens.
function resize() {
const dpr = Math.min(window.devicePixelRatio || 1, 2);
canvas.width = Math.floor(canvas.clientWidth * dpr);
canvas.height = Math.floor(canvas.clientHeight * dpr);
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
}
addEventListener("resize", resize);
Capping at 2 is a trade between sharpness and speed. On a low-end phone, the saved fill-rate is the difference between smooth and choppy.
4. A fixed timestep for game logic
Run game logic at a fixed rate (for example 60 Hz) and render as often as the screen allows. This keeps behavior consistent between a 60 Hz phone and a 120 Hz one.
5. Pause when hidden
Listen for visibilitychange and pause. Otherwise a backgrounded game can accumulate a huge time delta and teleport everything when you return.
6. Audio needs a gesture
Mobile browsers require a user gesture before audio plays. Create or resume your audio context on the first tap, and make sure muting works.
7. Respect small screens and safe areas
Keep important UI away from notches and rounded corners with env(safe-area-inset-*). Test portrait and landscape.
8. Load fast
For quick games to play, the first paint matters more than anything. Keep the game to a single small file where possible, avoid blocking scripts, and lean on drawing with code instead of loading large images.
9. Store progress defensively
Wrap localStorage in try/catch. Private windows and blocked storage throw errors.
10. Test on real devices
Emulators miss touch latency, memory pressure and thermal throttling. Even one older phone teaches you a lot.
The payoff
If you get these right, you get what players are really searching for when they look for no install browser games and HTML5 games: something that opens fast and plays well on the device already in their hand.
You can see the result in games like Instant Fruit Slice, which supports multi-touch.
What would you add to this checklist?
These are single player browser games rather than io games, so there are no live servers to run. They are also free games for pc browser users, and games to play on phone free of charge.
Top comments (0)