When you absolutely, positively got to kill every whitespace in the file.
apt install npm #or however your OS installs npm npm install html-minifier -g html-minifier --input-dir existing_html_directory --output-dir output
But it’s relatively slow and it didn’t minify standalone css files.
A Go equivalent is minify
Assuming that you already have go configured, and its binary directory is on your $PATH:
go get github.com/tdewolff/minify/cmd/minify minify -r -o output_dir/ existing_html_directory
minify -r -o public public #And serve it locally to test (cd public && python3 -m http.server 8000)