What can I do to make my game load faster in web export?

Godot Version

4.3

Question

I export my simple 2d game to web (HTML5). When you first run the game, the game takes like a minute to load. The loading bar is kinda slow. Now this would be okay, if the next time you run the game the loading is instant (like it used to be for flash games back in the day) but how can I do that? Is it even possible in godot?

I created a very small web app in Godot. I have gotten feedback that it is slow to load on phones. Turns out it’s really based on their data plan and/or internet connection. It loads instantly on most phones. The entire app is 36mb uncompressed, 9k compressed.

It could also be the servers. If you uploaded your game to itch.io there are times of day when loading is slower. For example on Saturdays their speeds are crap.

I don’t know of any caching Godot has, but you maybe could do it yourself. You could save objects locally and then look to see if they’re stored there before loading them. Or you could host data on your server and load it as needed or in the background once the main game has loaded.

This is already in the realm of web development. If you have your own domain, then one of the easiest things to throw at the problem is Cloudflare. If not, then your options are limited. Look for ways to reduce your game size and see if you can get caching HTTP headers sent with your resources.

Size-wise your visual assets will probably be the biggest part, so check out if you can use better and more aggressive lossy compression. WebP is nice, but I don’t know if Godot understands it.

In addition to cache headers, you could also add a service worker to manually control caching and update behavior. However, not sure if this plays well with Godot, but I can also not think of why it shouldn’t work. Also, this won’t speed up the initial load of the core engine.

To bring down bundle size, you could split your app into multiple PCKs that get loaded as required. Never did this, though, but would be interesting to see :grinning: And again, core engine download is not affected.

I heard of building a custom Godot binary that only ships parts of the engine that you really need. Read about this forum or on some blogs - don’t remember. That could be an option but of you need almost everything anyways, the opportunity might be limited.

So please take this post with enough grains of salt :smile: