Most browser "Accept-Encoding": "gzip", so the server could do this on the fly. There are also other encodings.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
Another option is to have .gz files besides the "real" file and serve that instead, to save CPU.
This would be an option of "file_server", perhaps with a fallback in the global namespace.
https://pkg.go.dev/github.com/mkch/burrow/compress
This seems to implement this using only the standard library. But only for the on-the-fly case.
For reference, Caddy has: https://caddyserver.com/docs/caddyfile/directives/encode