views:

449

answers:

3

This is likely a duplicate of the below question but the only answer is a dead link:
http://stackoverflow.com/questions/255008/minify-html-output-of-asp-net-application

When working with ASP.Net one of the more annoying aspects to me is the fact that Visual Studio puts spaces instead of tabs for white spacing which increases the size of the final HTML. I originally thought of simply changing Visual Studio settings to use tabs instead but then others on my team will still end up overlaying with spaces anyway.

My question is two fold: first is there a way to on a per project setting to change if spaces or tabs are used (and is it even worthwhile if so) and second, is there a way to simply minify all of the views when generated?

+9  A: 

Enabling GZIP will have much more effect than minifying your HTML, anyway.

naivists
+1. You should be compressing your output on transfer anyway, and when you are then a tab and a few spaces will take effectively the same bandwidth.
bobince
Where would the two Filters go inside the MVC folder hierarchy?
Maxim Zaslavsky
+4  A: 

I agree that the gzip response is the 'right' strategy. To answer your question, though, the easiest thing would be to get or make a simple executable for stripping whitespace, and then putting that into your project's build as a custom build step. this article : http://encosia.com/2009/05/20/automatically-minify-and-combine-javascript-in-visual-studio/ talks about doing that when minimizing and combining javascript, but the same technique would work for views.

Paul
Visual studio actually allows to find/replace using regex. So, you can find all `\s{8}` and replace them with `\t` (dunno if such syntax works, but something similar would)
naivists
of course, but that's still a manual step. That's why I suggest doing it in the build step.
Paul
Thanks, this is extremely helpful!!
mynameiscoffey