How to Minify Godot's Build Size (93MB --> 6.4MB exe)

Hey folks, I just made a post where I dramatically reduce Godot’s export size by using various techniques. Some sacrifices to performance were made, but this should serve as a guide to anyone looking to shrinking their file size (say for example if you’re sharing webgames or small applications).

28 Likes

That is amazing! Thank you for sharing. Will be coming back to this in the near future when I am ready for exporting. Thankyou very much.

Fantastic write-up!

I think your final builds download is the same web.zip for both the windows and web link. Stating the version would help make these links more useful, but ultimately I think uploading your final custom.py profile would be more helpful for future and previous version builds.

I think your final builds download is the same web.zip for both the windows and web link.

Whoops! Fixed that now.

I didn’t upload the custom.py file since I was worried people would just copy/paste it. What you should have in the file depends specifically on what your game uses. Here it is anyway for reference:

# custom.py
target="template_release"
debug_symbols="no"
optimize="size"
lto="full" # Slower build times, smaller export size

disable_3d="yes"
disable_advanced_gui="yes"

deprecated="no"  # Disables deprecated features
vulkan="no"      # Disables the Vulkan driver (used in Forward+/Mobile Renderers)
use_volk="no"    # Disables more Vulkan stuff
openxr="no"      # Disables Virtual Reality/Augmented Reality stuff
minizip="no"     # Disables ZIP archive support
graphite="no"    # Disables SIL Graphite smart fonts support

modules_enabled_by_default="no"
module_gdscript_enabled="yes"
module_text_server_fb_enabled="yes"
module_freetype_enabled="yes" # Needed alongside a text server for text to render correctly
module_svg_enabled="yes"
module_webp_enabled="yes"
module_godot_physics_2d_enabled="yes"
5 Likes

I posted “thanks” on Reddit, but I’ll post here as well. Very nice write-up!

1 Like

Thanks! And yeah, though digging through scons -h is not much fun, I think your list is a great starting point!

Great writeup, thanks a lot for the detailed breakdown! It already helped me to know the wasm-opt parameters to use for godot 4.4 (The one’s we talked about back then did had little to no effect for 4.3+).

Do you know of any repo already having some CI to build docker images with custom godot templates? I guess that would be potentially an interesting addition for my loading test repo.

Great article. Really well put together. I Ko-Fi’d you a coffee.

2 Likes

Hey folks, I updated the article to Godot 4.5. Some new options were added that allowed me to squeeze the Windows export size down to 5.37MB!

You’ll find a new section in the article talking about that. The bad news is, the web build’s size seems to be mostly unchanged.

I’m only half a year late :sweat_smile: but sadly no. Now I’m interested too, if anybody set up a custom CI for this, please do share.

4 Likes

Wouldn’t that be nice?

thanks for the custom.py. suprise me a lot.

can i ask about:

  1. is there any document( offical /unoffical) for how to write this?
    Godot build options generator is the doing the opposite thing.
    plainful to guess which modules to keep.

  2. look like “build options” and “Engine Compilation Configuration Editor” is kind of overlap.
    can i just use the profile godot 4.5 generated?

The building from source section in the documentation has a lot of detail on how to setup the build system and its options. Which modules to keep unfortunately takes some guessing, but you can see the list of all available options and modules with scons --help. Remove the ones you know aren’t going to be used by your project for sure.

The build profile helps with size, but if you want the maximum gains you have to manually pass in build options.