Minify HTML with .NET MVC ActionFilter
To make our site a tight as possible, I thought we’d explore the idea of removing the white space in our generated HTML.
I’ve had this idea for a long time, but after reading @hugoware post about removing white space, I decided to implement it in my own projects. As with any good code, let’s stand on the shoulder of giants and make it fit our needs.
Normally, if we did a “View Source” on our web page we would see something like this:
Now a lot of good HTML developers like to leave closing html comments and notes in their code. This helps them track end elements in nested code. For example:
<div id="wrap">
<div id="content">
content goes here, with more elements of <>
</div> <!--end content-->
</div> <!--end wrap -->
The issue we may face on larger pages is there can be a lot of notes and end line comments which can add to the overall size of your page, which the user doesn’t care about but the developer needs for easy editing later. Read more…




