https://github.com/thinknathan/def-html5-opt
Nodejs tool that adds loading and caching optimizations to HTML5 web games exported from Defold
https://github.com/thinknathan/def-html5-opt
defold defold-game-engine
Last synced: 4 months ago
JSON representation
Nodejs tool that adds loading and caching optimizations to HTML5 web games exported from Defold
- Host: GitHub
- URL: https://github.com/thinknathan/def-html5-opt
- Owner: thinknathan
- License: cc0-1.0
- Created: 2023-12-27T23:52:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-25T16:40:20.000Z (5 months ago)
- Last Synced: 2026-01-26T09:18:16.806Z (5 months ago)
- Topics: defold, defold-game-engine
- Language: JavaScript
- Homepage:
- Size: 938 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# HTML5 Build Optimizer for Defold
[](https://github.com/thinknathan/def-html5-opt/actions/workflows/ci.yml)

Adds loading and caching optimizations to HTML5 web games exported from [Defold](https://defold.com/).
1. Minifies HTML and JS to reduce file size and speed loading
2. Adds preload meta tags to speed up first boot
3. Generates a service worker to persistently cache assets
## Install
1. Install [Nodejs](https://nodejs.org/en) or equivalent
2. Clone this project (or fork it in Github)
`git clone https://github.com/thinknathan/def-html5-opt`
3. Install dependencies
`npm i`
or
`yarn`
## Usage
1. Build your HTML5 export from Defold
2. Copy your game files into the `copy-game-here` folder (don't include the build report: exclude `report.html` and similar)
You can skip any of the following steps you don't want to run. This is the recommended order:
3. Run `yarn preload` or `npm run preload` to add preload meta tags
4. Run `yarn minify` or `npm run minify` to reduce the size of `index.html` and `dmloader.js`
5. Run `yarn sw` or `npm run sw` to generate the service worker
Done! We've completed the modifications to your game in the `copy-game-here` folder.
Upload all the files inside `copy-game-here` to distribute your game.
## Other potential optimizations
Since Defold's usage of `emscripten` lags behind the latest release, you may be able to gain an improvement to speed and/or file size by downloading the latest version of [wasm-opt](https://github.com/WebAssembly/binaryen) and running it on your wasm binary.