Minimize Web Build

by aturbidflow

20

Recent updates

  • Threads & PWA support
  • Custom templates support & disabled Head Includes override
  • itch.io & servers with gzip compression support

How it works

The add-on resaves large files (.pck, .wasm) with gzip compression, minifies core files (.js and .html) and adds the ability to load gzip-compressed assets in the browser using pako. Nothing else will be changed in your files.

Usage

  1. Install the addon from AssetLib or from source (copy addons folder to your project directory)
  2. Enable the plugin in your Project Settings.
  3. Export your project to Web.

Detailed explanation

Step-by-step algorythm

  1. Godot creates release files.
  2. The addon copies additional and temporary files to the build directory (pako.js, compressor, minifier)
  3. Using a tool written in Go (see /vendor/bin/compress/src in the plugin directory), the .pck and .wasm files are converted to a gzip enconding
  4. Using minify by tdewolff, the core .html and .js files are minified.
  5. Using some crappy code, parts of the core JS and HTML files are slightly adapted to support the use of pako.
  6. The directory is cleared of temporary files (compressor, minifier).

Why Golang compresser?

It was painful to implement the encoder directly in Godot because of the "original" implementation of Gzip conversion. You can create a PR if you are brave enough to implement it.

Is it necessary to minify?

Nope, it does save a bit of size compared to gzip, but it makes js easier to update.

FAQ

Custom templates support

Honestly, it hasn't been tested. But you can try. If it doesn't work, feel free to create an issue.

Why Godot 4.0 - 4.2 aren't supported?

Because Godot had a broken web build until version 4.3. Actually, the addon works and compresses files on older versions, but the web build still doesn't work, so I don't recommend using it.

What about Godot 3.x?

There are no plans at the moment.

@aturbidflow – Telegram

Version

1.0.4

Engine

4.3

Category

Tools

Download

Version1.0.4
Download

Support

If you need help or have questions about this plugin, please contact the author.

Contact Author