views:

543

answers:

5

Obviously having whitespace in css, aspx and html pages is a great advantage at design time. But is there a way to (a tool that will) clear all the whitespace from all the files and possibly merge javascript and css files in a more optimal way.

I am using asp.net themes so there are quite a lot of separate css files that would be improved through some form of automated combining. I have seen a few http modules but that isn't quite what I want I just want to run something over the published project beofre sending it to the server.

EDIT: Compression at least in IIS is unfortunately not an option, we are currently running it on the same IIS server as a third party web based student management system. It doesn't like compression and the IIS options don't seem to be per application pool. I did apply asp.net compression but the bulk of my extra data seems to be the app_themes which I know would compress well I just don't want to have to manually go through compressing all the css separately.

+1  A: 

An empirical study on the effect of removing white space from a not-untypical website (Drupal) showed minimal effects. (site also contains some links to non .net html white space removal tools)

I have gotten magical improvements in page size by aggressively managing viewstate size and using Blowery's http compression module.

Another strategy is to do minifiation (merging many css files into one). Telerik has such a component RadStyleSheetManager, it works only with style sheets embedded into assemblies.

MatthewMartin
not true with css in app_themes as there are multiple css sheets that should be compacted and possibly merged to reduce not just physical size but also the numbe rof separate http requests
PeteT
What isn't true? Anyhow, I did suggest RadStyleSheetManager which does what you recommended.
MatthewMartin
It might not significantly improve performance, but it can improve bandwidth consumption and cost. For those who have bandwidth caps and a fair amount of traffic, the savings add up quickly.
joseph.ferris
+1  A: 

I think one of the reasons that this was never included in .NET was because they expected you to turn on server compression in these scenarios. IMO I don't agree with this -- I think it's a shame that at least aspnet_compiler.exe can't do this optimization. It would be such a great performance boost on uncompressed connections. Anyway, you can enable compression on IIS 6:

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true

And it's even easier and more flexible in IIS7 to do so. I hope someone has a better solution than I!

Dave Markle
Especially true when you don't have or it is difficult to get access to the web server to change the settings.
PeteT
A: 

4 guys from Rolla just published an article on a http module that removes white space. You would need IIS 7 in integrated mode to make it work for css (or possibly IIS6 with wildcard mappings)

It looks more like a proof of concept, but the code is free.

MatthewMartin
+1  A: 

There is another way http://omari-o.blogspot.com/2009/09/aspnet-white-space-cleaning-with-no.html

OmariO
A: 

i found this:

http://msdn.microsoft.com/en-us/library/aa719805(VS.71).aspx

greets!

Elmer