How to bundle a Defold game for HTML5
Updated
Defold is built for small, fast games, which makes it a good fit for the browser. Its HTML5 bundle gives you a folder you can zip and upload. This guide covers how to bundle a Defold game for the web, what to check before you upload it, and the mistakes that cost people the most time. Menu names can change between Defold versions, so check the current Defold manual if something looks different.
Before you bundle
- Plan for the web from the start. Test in a browser early, not the night before a jam ends. A game that works on desktop can behave differently in a page, especially with sound, input and file access.
- Keep the size in mind. Players download your game every time they open it. Compress your textures, trim audio, and remove assets you do not use. See how to make your browser game load fast.
- Do not rely on the network. On indiedev.games a game cannot call other sites, so ship everything inside the bundle.
- Choose a screen size that fits a page. Set the display size and how the game scales in
game.project, then test it in a small window as well as a large one.
Bundle step by step
- In the Defold editor, choose Project, Bundle, HTML5 Application.
- Choose a release variant for the version you share. Debug variants are larger and include tools players do not need.
- Pick an empty output folder. Defold writes the page, the engine script and WebAssembly files, and your game data into it.
- Open the folder and check that
index.htmlis in it. If your bundle sits inside a subfolder, zip that folder's contents soindex.htmlis at the top of the zip. A zip that holds a single folder is also accepted on indiedev.games.
Test it before you upload
Do not double-click index.html. Browsers block the files a web game needs when they come from your disk. Use a small local web server, or the editor's own web build and run command if your version has one, and then check:
- The game starts with no errors in the browser's developer tools console.
- Sound plays after the first click or key press. Browsers block sound until the player interacts, so offer a start screen.
- The game looks right in a window of the size players will really have, including a phone if you claim to support one.
- Touch or mouse input works, and the game does not need a key that a browser keeps for itself.
Common problems
- Saves that do not stay. Browser storage may be limited in a sandboxed page, so test saving and loading in the place you will publish.
- Missing files. If a file loads on your computer but not online, the usual cause is a wrong path or a name with different capital letters. Web servers care about case.
- A very slow first load. Check the size of the archive file in the bundle and shrink the biggest assets.
- Extension code that only works on desktop. If you use a native extension, check that it supports the HTML5 platform.
Upload it
On indiedev.games, see Upload and publish a build for the limits and how versions work, and how to prepare your game page for the text, pictures and age label. Then add a few lines of Lua to count what players do, with Send game events from Godot or Defold.
Before you share the link, check the rest of your page with the store page readiness checker.