Once you have seen a PC game open in a browser tab, the next question is the one I could not leave alone. How is that even possible? Browsers were built for documents and scripts, not for a 2000 racing game with its own renderer, audio mixer and save format. I am still a modder and vibe coder learning in public, not a graphics engineer, so I wanted a plain explanation of the machinery.
This Game Dev Series post is the companion to the one about what you can actually play today. I will not lean on unpublished links here. If you want the examples, legal notes and official services, read that companion first, then come back for the how. For background on engines themselves, the game engines post is a good start, and the cloud gaming post covers the streaming side in more depth.
The short version is this. Sometimes the browser is a window onto a remote computer. Sometimes the browser really is the computer, running a compiled game through WebAssembly and drawing the frame with WebGL or WebGPU. Those two designs only look the same in a screenshot.
What are the two ways a PC game can ‘run’ in a browser?

In a local port, the game logic lives in your tab. Your key presses stay in the browser, the simulation steps forward, and the page draws the next frame to a canvas. After the first load, a well-built port can even keep working if the network drops, because the program and, if you imported them, the assets are already on the machine.
In cloud streaming, your browser is a thin client. It sends input to a server, the server runs the real Windows or console build, and a video plus audio stream comes back. I will not repeat the full latency budget here, because I already walked through it in the cloud gaming guide. The important technical point is that no amount of WebAssembly is required on your side. Your device mainly decodes video.
People say both of these are ‘no download’ because you did not run a store installer. A local port may still pull tens or hundreds of megabytes the first time, and a bring-your-own-files port may ask you to import a whole game folder into browser storage. The download did not vanish. It changed shape.
What is WebAssembly, in plain language?
WebAssembly, or Wasm, is a compact bytecode format designed so languages such as C, C++ and Rust can run in a browser at near-native speed. You almost never write it by hand. A compiler emits a .wasm module, the browser compiles that module to machine code, and JavaScript can call into it the way it would call any other function.
MDN describes the design goals clearly. It should be fast and portable, stay inside a sandbox, and work with the rest of the web instead of replacing JavaScript. That last point is why a game port is never ‘just a wasm file’. The module still needs a JavaScript layer to talk to the canvas, the speakers, the gamepad and the file picker, because WebAssembly cannot touch those Web APIs by itself.
Think of it this way. JavaScript is a flexible language for pages. WebAssembly is a low-level, tightly packed program that is good at heavy loops, physics, AI and rendering setup. Games need both. The hot code goes in the module. The browser glue stays in JavaScript.
How does Emscripten turn a C or C++ game into a web page?

Most older PC games were not written for a browser. They call operating system APIs, a graphics API such as OpenGL or Direct3D, and libraries such as SDL or OpenAL. Emscripten is a compiler toolchain, based on LLVM, that exists to port that kind of program to WebAssembly. Its own docs say it converts OpenGL into WebGL and supports familiar APIs such as SDL, pthreads and POSIX, as well as Web APIs and JavaScript.
MDN’s overview of the process is a good mental model. Emscripten feeds C or C++ into Clang and LLVM, emits a Wasm binary, then generates JavaScript glue that loads the module and implements those old libraries on top of Web APIs. If the game drew with OpenGL, the HTML page gets a canvas. If it wrote to stdout, the page may have a log box. If it used threads, the story gets harder, because browsers only allow shared memory between workers when the server sends special security headers.
Not every browser game is an Emscripten port of an old executable. New games often start in Unity’s Web export or Godot’s official HTML5 export, which also produce WebAssembly and a canvas, just from a modern engine instead of a 20-year-old Visual C++ project. Some reimplementations, such as OpenGTA and OpenNFSPU, compile one portable C module and run it on a small WebAssembly runtime both natively and in the browser. The idea is the same. The CPU work becomes Wasm. The picture becomes WebGL or WebGPU. The operating system calls become browser APIs.
How do WebGL and WebGPU draw the game?
WebGL is the older, widely supported way for a page to talk to the GPU and draw into a canvas. It comes from OpenGL ES, which is why so many ports map an old OpenGL renderer onto it. OpenNFSPU, for example, takes the original Direct3D 7 rendering and presents it through OpenGL ES 3.0, which is WebGL 2 in the browser. Godot 4’s official web export also targets WebGL 2.0 and the Compatibility renderer.
WebGPU is the newer API. MDN calls it the successor to WebGL, with better ties to modern native APIs, cheaper rendering of many objects, and first-class support for general GPU compute. Browser support is still not universal, and MDN marks it as limited availability. Unity’s current Web docs say a WebGPU build needs a secure context, so it will not just open from a file:// path. Official Godot 4, as of the stable web export docs I read, does not support WebGPU yet.
For a player, the practical difference is compatibility versus headroom. WebGL 2 is the safer target if you want the game to start in more browsers. WebGPU is the path engine vendors are moving toward when they want features that WebGL was never going to grow. Either way, this is still a web GPU API. It is not the same as a native Direct3D 12 or Vulkan install with full driver tricks, and that is one reason a demanding port can look or run worse than the original PC build.
How can a game in a sandbox read your files?

A normal desktop game can open any path on your disk. A website cannot, and that is a good thing. The browser sandbox keeps a page from quietly scanning your files. So how does a port load Grand Theft Auto or Porsche Unleashed at all?
The polite way is to ask you. The File System Access API lets a site show a file or folder picker. You choose the installed game folder or a disc image, and the page receives a handle to those files. A careful project then reads the data in the tab. OpenNFSPU’s playing guide says nothing is uploaded, and OpenGTA’s player says the same. That is the model I want more ports to follow.
Because picking a 500 MB folder on every visit is annoying, many ports also offer an import. The origin private file system, or OPFS, is a storage area private to that site. It is not shown in your normal Documents folder, it counts toward the browser’s storage quota, and clearing site data deletes it. MDN notes that it can be much faster than writing back to a user-visible file, especially for large updates, and that synchronous access is available inside a web worker. OpenNFSPU’s import uses about 520 MB of this storage. OpenGTA’s import is about 330 MB, mostly music.
You can also skip the import and read the live folder, but you will usually have to pick it again next time. Either way, the original maps and music stay yours. The site is an engine, not a file host.
Why do so many ports still need the original assets?

This is the bit that confused me until I separated code from data. A game program knows how to simulate cars, draw a city and play a radio station. The actual streets, liveries, voices and songs are data files, and sometimes even tables packed inside the old executable. OpenGTA’s game data guide is explicit. The project ships no game data of its own. It reads GTADATA and also loads tables from the original Grand Theft Auto.exe at run time. It never runs that executable. OpenNFSPU does the same with Porsche.exe, and it even checks a file size and checksum so you have the 3.5 patch.
That is why a clean port can be open source and still require a game you own. The code is new. The art is not. If a website already has those assets and streams them to anyone who clicks Play, it has crossed from ‘here is an engine’ into ‘here is the game’, and that is a legal line I will not blur.
Official web games are different because the publisher chose to ship the assets for the web, often in a smaller package. itch.io’s HTML5 limits, including a 500 MB default cap on extracted size, exist because a giant asset pack is a miserable page load even when it is fully legal.
How do audio, input and saves work in the tab?

Sound usually goes through the Web Audio API. Emscripten and engine exports translate the game’s old audio calls into buffers, panners and an audio context. Some tools, including js-dos, also mention an AudioWorklet mode so the mixer can run off the main thread. Browsers often block audio until you click, which is why so many web games start with a Play button. That click is not just design. It satisfies the browser’s autoplay rules.
Input is a bundle of APIs. The keyboard is easy. The Gamepad API covers controllers. Pointer lock hides the cursor so a first-person game can look around, and fullscreen is a separate request. Touch is possible, but most ports of keyboard PC games only bolt it on. None of this is as complete as a native input stack. Racing wheels, exotic gamepads or very high mouse polling rates are the first things to feel wrong.
Saves almost never go back into the original Program Files folder. They usually land in IndexedDB or in OPFS for that site. OpenNFSPU keeps players, options, track records and replays in the browser, and it lets you export or import a zip so you can move a career to the desktop build. That is good design. If a project has no export, your progress lives at the mercy of cache cleanup, a new device or a full disk that made the browser evict site data.
Why is a browser game still slower or heavier than the original?
Near-native is not native. The Wasm module has to be downloaded, compiled and kept in a sandbox with bounds checks. Graphics go through WebGL or WebGPU rather than the original Direct3D path, which may already be an extra translation. Audio and file access are asynchronous on the main thread unless the port moves work into workers. If the game wants real threads, the host must send Cross-Origin Isolation headers, and that can break everyday things such as third-party scripts on the same page. Godot documents this trade-off, and it is why its default web export is now single-threaded.
Size is the other limit. A local port still has to get the program, and maybe hundreds of megabytes of assets, into the browser. itch.io encourages developers to think of an HTML5 game like a website, because a long first load feels worse than a native installer you run once. Cloud streaming flips the problem. The first load can be fast, but you pay with a permanent, low-latency network path, and I have already said what that does to twitchy games.
Mobile makes every one of these costs worse. A phone has less thermal headroom, a smaller GPU, tighter memory, and a touch screen. Engine docs are blunt about this. A web export can skip the app store, which is lovely for sharing a demo, and still be the wrong way to ship a heavy game to a phone.
What does this mean if you want to build a web game yourself?
You do not start by reverse-engineering a commercial executable. You start with an engine that already exports to the web, you keep the asset budget small, you test on HTTPS, and you decide early whether you need threads, WebGPU or just a solid WebGL 2 build that starts after one click. For a learning project, that is a much kinder path than trying to swallow a 20-year-old PC installer.
If you do care about ports, the projects worth studying are the ones that document their data rules in the open, keep assets off the server, and offer a save export. That discipline is as much a part of the engineering as the renderer.
What tips help when you are learning this stack?
- Always ask where the simulation runs. If the answer is ‘a server’, you are looking at streaming, not a local port.
- Budget the first load. A 500 MB import can be fine once, and still be the wrong idea for a casual link you send a friend.
- Test in more than one browser, especially if you touch WebGPU, gamepads or pointer lock.
- Put a click-to-start screen on anything with sound.
- Offer a save export if progress matters. Site storage is not a hard drive.
- Read the engine’s web export notes before you promise threads, C# on the web, or mobile performance.
- Keep copyrighted assets out of the repo and off the web root unless you have the right to distribute them.
What common mistakes show up in browser ports?
- Opening the build from a file:// URL, then wondering why it fails. Unity is explicit that browsers block this, and WebGPU needs a secure context.
- Assuming WebGPU is available everywhere. It is not, and official Godot 4 still targets WebGL 2.
- Forgetting that clearing site data can wipe both imported game files and saves.
- Treating a folder picker as an upload form. If your code sends those bytes to a server, you have changed the product and the trust model.
- Shipping a huge unoptimized asset pack because ‘the engine can export it’. The engine will. Players will not wait.
- Copying commercial game files into a public folder so the demo is one click. That is not a technical shortcut I will help with.
Frequently asked questions
That is the machinery behind the clips of old PC games in a tab. The browser became a serious runtime, but it is still a sandbox with a GPU API, a storage quota and a legal line between an engine and a game’s data. Next in this series I want to look at building a new web game from scratch with tools such as Three.js, which starts from a page and a renderer, not from an old executable.





