Put your game on a web host
A wasm-release build from Build for the browser has three runtime
files plus its notices and build record, and any web server that serves static files can host
them. This page says what the server has to
send with them, and what goes wrong if it does not. Labrador’s own demo,
LineSweeper on mattharding.dev, is on such a host.
To put your game on one free host step by step, with every command, see Put your game on the web: it publishes the release with GitHub Pages, which sends everything this page asks for.
The files
Section titled “The files”| File | What it is | Size for the template, wasm-release |
Under Brotli |
|---|---|---|---|
MyGame.html |
The page, made from your web/shell.html |
1.2 KB | 0.5 KB |
MyGame.js |
The script that loads and starts the module | 119 KB | 27 KB |
MyGame.wasm |
The engine and your game, with your content packed into it | 376 KB | 117 KB |
NOTICE.txt |
The engine, content and toolchain notices, with full licence texts | Depends on the notice inputs | |
BUILD.json |
Source identity, build type, toolchain version, file sizes and hashes | Depends on the files |
Use the browser release command
to gather all five in out\web-release, then upload that folder’s contents together. Link
NOTICE.txt from your hosting page: one line in game\web\shell.html, such as
<p><a href="NOTICE.txt">Third-party notices</a></p> after the status line, puts the link on the
game’s own page at the next build, as step 1 of
Put your game on the web shows. Edit shell.html, not the built
MyGame.html, which every build writes again. The game page names the script and module by relative path,
so the folder can be anywhere on the site. There is no separate content file to upload, because
--embed-file packs the content into MyGame.wasm; a game with more content has a larger
module rather than more files. The sizes were measured on 25 October 2026 from the project Get
Started builds, with Emscripten’s release settings and Brotli at its highest quality; your game’s
will be larger as it grows.
What the server must send
Section titled “What the server must send”The game is single-threaded, so the list is short.
-
.wasmfiles asContent-Type: application/wasm. Most servers and hosting services already do. With another type the page still starts, but more slowly: the browser cannot compile the module while it downloads, and falls back to downloading it whole and compiling it afterwards. The console shows the failure and the fallback as two messages:wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly':Incorrect response MIME type. Expected 'application/wasm'.falling back to ArrayBuffer instantiationThat is what Chrome did when the template’s page was served with
.wasmasapplication/octet-stream, on 25 October 2026. The page drew and played as usual. Fix the type anyway: a page that logs errors on every load hides the next real one. -
No cross-origin isolation headers.
Cross-Origin-Opener-PolicyandCross-Origin-Embedder-Policyare needed only by a module built with threads, and Labrador’s browser build has none. Leave them unset:require-corpmakes every cross-origin image, script and frame on the page fail unless that resource opts in. -
If the site sends a
Content-Security-Policy, itsscript-srcmust include'wasm-unsafe-eval', or the browser refuses to compile the module and the game never starts. The page stays at its loading line, and the console says that compiling or instantiating WebAssembly violates the policy. The template’s page also runs an inline script, so a policy for it needs'unsafe-inline'as well, or a hash of that script:Content-Security-Policy: script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'With that header the template’s page started and quit as usual in Chrome on 25 October 2026, and without
'wasm-unsafe-eval'it stopped before its first frame. A site that sends no policy needs none of this. -
HTTP or HTTPS, but not
file://. A page opened from disk cannot load its module. Serve it over HTTPS on a public site: browsers give the Gamepad API only to secure pages, of whichlocalhostand127.0.0.1are two while you develop. That is the browsers’ documented rule rather than something checked here.
Compression
Section titled “Compression”The module and its script compress well, as the table shows. Most hosting services compress them
on the fly with Brotli or gzip when the browser asks, which is all a game needs. A server you run
yourself should compress .wasm and .js responses, or serve copies compressed in advance with
the matching Content-Encoding. Either way the Content-Type stays application/wasm.
Caching
Section titled “Caching”Emscripten writes the same three file names on every build. If the server tells browsers to keep
MyGame.wasm for a long time, a player can be served a new page with an old module. Either:
- let every file be revalidated, which is what
Cache-Control: no-cacheasks for and what many static hosts do by default, so a returning player downloads only what changed; or - put the
.jsand the.wasmin a folder named for their contents, such as a short hash, point the page at that folder, and send those two withCache-Control: public, max-age=31536000, immutableand the page withno-cache. A new build is then a new folder, and the page that names it is never stale. LineSweeper’s demo does this.
The page names MyGame.js in a script tag, which the wasm-release build writes as
<script async src=MyGame.js>, and the script loads MyGame.wasm from its own folder. To put
both in a folder such as a1b2c3, change that tag in the built page to
<script async src=a1b2c3/MyGame.js> after every build and before uploading, or have your upload
step do it; the edit is lost when the page is built again.
Documentation for Labrador v0.3.0. Built from Labrador 0f4f503 of 2026-11-03.