How do I reduce the size of my Web builds?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By xyber

Hi all!

I am looking for ways to reduce the build size for Web.

I made an empty scene with a low poly model (200 KB in size), and just making a build out of it, the build folder’s size comes around 24 MB.

The .wasm file comes around 19 MB, while the .pck file comes around 180 KB, which seems excess for a nearly empty game scene.

I searched around for a while, and followed this guide to reduce the size : (Reddit - Dive into anything)

Following it, I compressed the .wasm and .pck file, and the build came out to be 5MB. But it’s still a bit big, I need even an smaller size.

I need to reduce it even further.
Also, I am aware of stripping the engine and compiling it, which I’m saving as the last step. Also, I am quite unsure of how to approach this whole “building” thing works.

Do any of you have any ideas for this?

:bust_in_silhouette: Reply From: Zylann

That 19 Mb is the cost of having a fully-featured engine that remains as easy to use for small and large games while targetting any kind of platform. 5 Mb is actually a very good compression ratio for something as featured as Godot.

If you want to reduce it further, the last thing you can do is indeed compile it by stripping features you don’t want, as explained in Optimizing a build for size — Godot Engine (stable) documentation in English
Not everything can be stripped, as it becomes increasingly difficult to do so without starting to breaking interdependent parts of the engine (while some others still need to be improved to support stripping).

If this is still not enough, then the question of using Godot at all rises. If your game is going to be smaller than perhaps 4 Mb, you could be using something more dedicated to the web platform, like Three.JS directly with Javascript.

Note: if you have separate .pck and engine runtime, I can imagine that your browser can actually cache the engine file so it won’t reload it next time you go on the page, if the engine file didn’t change of course.

:bust_in_silhouette: Reply From: ProggerParrot

Web games in particular are difficult to minimize, since you still want to be available on as many platforms as possible.
The best approach here is to keep all resources as small and optimized as possible, which is then expressed in a small .pck file.
For the rest you have to start cutting the engine piece by piece.

The video here will surely help you:

PS: Most online-hoster also compress their games to save server-storage (like itch.io or GotM)