tdewolff / minify

Go minifiers for web formats

Home Page:https://go.tacodewolff.nl/minify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows binary only for HTML minification part

dehghani-mehdi opened this issue · comments

I'm not familiar with Go.

Right now the size of the exe file is +4MB and it's too big for my use case, and I just need the HTML minification feature, is there any way to split the exe file?

Hi Mehdi, using the original Go compiler (or gc) will always results in large binaries 6 MB upwards, even a simple hello world. The difference of only a HTML minifier or all minifiers is probably a differences of much less than a megabyte. The "problem" is that gc compiles statically and contain all code it requires. There's no way to reduces this besides using the -ldflags "-s -w" -trimpath options to go build (which are already applied to the binaries on GitHub).

You're only option is to use UPX which now supports Go binaries at the cost of a small performance hit on start-up (in short, it compresses the executable and extracts itself upon execution), or you could try the gcc-go compiler, which compiles dynamically to all system libraries and will result in significantly smaller executables (much like the gcc for C programs). I don't think TinyGo will be able to compile the library, but that would be even smaller still.