In my last post, I wrote about an HTML minification middleware I use in my ASP.NET Core projects. In this post, I want to write about why HTML should be minified. Most likely, with everything else that's minified nowadays, you may be thinking it's for reduced network transfer and increase performance. You're right, but that's not all. In fact, to me, that's not even the most important reason.
The most important reason is CSS. When HTML is minified, and its whitespace is removed, it makes it much easier to style with CSS. If you don't remove whitespace, then it causes annoying styling issues by altering the dimensions of an element on the screen and bumping other elements around. You then must do weird trickery within your stylesheets to correct for that.
It's much easier to simply not worry about that AND get the benefit of lower network transfer and higher performance. Pretty simple, eh?
If you're using ASP.NET Core and are interested in HTML minification, then I recommend giving my middleware a try. You can find it on NuGet under Arex388.AspNetCore. That being said, while I don't intend for it to be volatile, it may be because it was spawned from my need to share code between my projects and as such as my needs change so will it. The HTML minification middleware will always be there though.