← THE BLUE STICK

Guides / Free and browser gaming

How Do Browser Games Work?

PLAY NOWSolo, free, in your browser

You click a link, a page opens, and a few seconds later you are playing. No installer ran and no app was added. What happens behind the scenes is straightforward.

What happens when the page loads

A browser game is a website. When you open it, your browser asks a server for the page and receives a set of files.

File typeWhat it isRole in a game
HTMLThe structure of the pageWhere the game sits and what surrounds it
CSSThe stylingMenus, buttons and layout
JavaScriptProgram codeThe rules, movement and logic of the game
WebAssemblyCompiled codeThe same job as JavaScript, for games built in other languages
ImagesPictures and sprite sheetsCharacters, backgrounds and interface art
AudioSound filesEffects and music
DataText files, often JSONLevels, settings and translations

Your browser downloads these, usually within seconds, and runs the code. From that point, everything happens on your own device. The browser acts as a small computer inside your computer, running the game in a tab.

Small games such as 2048 or Wordle are well under a megabyte. A 3D shooter such as Krunker is tens of megabytes. Either is tiny beside an installed game.

How the game draws and plays sound

Modern browsers have features built in that once needed plugins.

FeatureWhat it doesArrived
CanvasA drawing surface the game paints shapes and images ontoFirst shipped by Apple in 2004, later standardized
WebGLAccess to the graphics chip for fast 2D and 3D2011
Web AudioPlays, mixes and positions soundsEarly 2010s
WebSocketsA live two-way connection to a server2011
Gamepad supportReads console controllersMid 2010s
WebAssemblyRuns code from languages such as C++ and Rust at close to full speed2017
WebGPUA newer, more capable link to the graphics chipFrom 2023

WebAssembly is how large games built with engines such as Unity and Godot reach the web. Many smaller games are written directly in JavaScript, often with a framework such as Phaser or Three.js.

The game loop

At the heart of every action game is a loop that repeats many times a second.

  1. Read input. Which keys are down, where the mouse is, where fingers touch.
  2. Update the world. Move everything, check for collisions, apply the rules.
  3. Draw the result.
  4. Wait for the next frame, then repeat.

The browser offers a way for a game to run this loop in step with the screen. On a 60 Hz display the loop runs 60 times a second, giving the game 16.7 milliseconds to do all three steps. If the work takes longer, a frame is missed and the game stutters.

When you switch to another tab, most browsers pause or slow the loop to save power, which is why a game may freeze in the background and why a well-made one pauses itself.

The same game often has to work with a keyboard and mouse on a computer and with fingers on a phone. Browsers report all of these, and a well-made game listens for each, which is why it can show on-screen sticks on a phone and none on a laptop.

Saving and multiplayer

A browser game can store data on your device, in storage the browser keeps separately for each website.

StorageTypical limitUsed for
CookiesA few kilobytesSign-in and preferences
Local storageAbout 5 megabytes per siteProgress, settings, best scores
IndexedDBMuch largerBigger saves and downloaded game files
Cache storageLargeKeeping the game's own files so it loads faster, or offline

This is why clearing your browsing data can erase a save, why a private window forgets everything when closed, and why progress does not follow you to another device unless the game offers an account or a backup code.

For multiplayer, the game keeps a connection open to a server, usually a WebSocket, and exchanges small messages many times a second. The server passes information between players, decides disputes and keeps things fair. Games such as Agar.io, Slither.io and Krunker work this way. A newer technology, WebRTC, lets browsers also talk directly to each other, which some games use for voice or for two-player matches.

What can go wrong, and how to fix it

ProblemLikely causeFix
The game will not startAn old browser, or a blocked scriptUpdate the browser. Try turning off extensions for that site
No soundBrowsers block audio until you interactClick or tap the game once
Choppy graphicsHardware acceleration is off, or too many tabsTurn it on in the browser's settings, and close other tabs
Progress vanishedBrowsing data was cleared, or you used a private windowUse a normal window and the same browser each time
Laggy multiplayerNetwork delayMove closer to the router, or use a cable
The keyboard scrolls the pageThe game does not have focusClick inside the game, or go full screen
Freezes when you switch tabsThe browser paused the tabKeep the game in the front tab
Black screenGraphics driver troubleUpdate your graphics drivers, or try another browser

Because everything runs inside the browser's own safety boundary, a browser game cannot reach into the rest of your device the way an installed program can. And because nothing is installed, trying one costs you only a few seconds. A complete game arrives the same way a web page does and works on almost any device with a browser.

PLAY NOWSolo, free, in your browser