Adds loading and caching optimizations to HTML5 web games exported from Defold.
- Minifies HTML and JS to reduce file size and speed loading
- Adds preload meta tags to speed up first boot
- Generates a service worker to persistently cache assets
-
Install Nodejs or equivalent
-
Clone this project (or fork it in Github)
git clone https://github.com/thinknathan/def-html5-opt -
Install dependencies
npm ioryarn
- Build your HTML5 export from Defold
- Copy your game files into the
copy-game-herefolder (don't include the build report: excludereport.htmland similar)
You can skip any of the following steps you don't want to run. This is the recommended order:
- Run
yarn preloadornpm run preloadto add preload meta tags - Run
yarn minifyornpm run minifyto reduce the size ofindex.htmlanddmloader.js - Run
yarn swornpm run swto 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.
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 and running it on your wasm binary.
