Jekyll by itself does not compress. However, consider basing your layouts on this: http://jch.penibelst.de
Works well, though does not play nice with //-style comments in JavaScript; need to convert to /* … */.
One more thing: If you’re using Sass, config like so:
sass:
style: compressed # minification of compiled CSS
you can use a node package to do it - html-minifier. Or Gulp tasks can do the same type of thing. Not sure about the comments, that is probably an option.
I use AWS amplify for a site and have that along with some other stuff minifying things, here is my package.json file.
if you have node installed, you could add this to your project directory and then do npm i to install the dependencies and then npm run deploy should build your site and miniize all the things. Assuming you have paths setup like I do.
If you are not familiar with node then I probably wouldn’t recommend doing this.
Not answering your question directly, but I went back and forth on minification a few times. My best experience was with using the minification of the CDN one of my sites is using. But that one also didn’t handle Alpine shorthand well (@click="":class=""). Then I just search/replaced most of my HTML comments with Liquid comments ({% comment %}). I also use dashes more often: {%- -%}, to remove the leading and trailing spaces.
With GZIP enabled on the server, the remaining spaces really don’t impact performance.