views:

825

answers:

6

Is there any native compression (for javascript/css files) available in ASP.NET?

+1  A: 

There is Gzip/Deflate compression support in IIS compatible with all modern browsers except IE6. For IIS 7 check this page: http://www.iis.net/ConfigReference/system.webServer/httpCompression

Artem K.
+2  A: 

You could use Packer.

This utlity supports JavaScript compression and /or "minifying", and CSS "minifying".

It's available as a command line utility or also as an MSBuild task. This way you can integrate it into your build process / Visual Studio project.

kay.herzam
Great minds think alike ;-)
RedWolves
+2  A: 

In the appendix of Professional ASP.NET 3.5 Scott Hanselman talks about Packer for .NET. This will integrate with MSBuild and pack javascript files for production deployments etc.

RedWolves
It seems we posted the same answer at the same time :-)
kay.herzam
Looks like Packer is the closest thing that comes to native compression in .NET.
dev.e.loper
On Packer page there is a section "Packer versus JSMin" which says that JSMin can be more efficient than Packer. On Yahoo Compressor page (http://developer.yahoo.com/yui/compressor/) it states that Yahoo compressor is more efficient than JSMin, so it looks like Yahoo compressor might be a good candidate even though its not native to .NET environment.
dev.e.loper
From Packer's website: "While Packer can created a much smaller output file it can be more problematic with packing JavaScript that does not conform to a strict syntax"... Sounds scary, like it might mangle my javascript?
Frank Schwieterman
+1  A: 

Further to other answers and comments, you can use Yahoo!'s YUI Compressor and make it an MSBuild Task to integration it into your build and deployment process.

Grant Wagner
helpful. thank you.
dev.e.loper
A: 

I have written something to do this for me, you can download it here: http://www.picnet.com.au/blogs/Guido/post/2009/12/10/Javascript-runtime-compilation-using-AspNet-and-Googles-Closure-Compiler.aspx

It uses Google's closure compiler which is pretty awesome.

Thanks

Guido

gatapia
+2  A: 

Try Chirpy. It mashes, minifies, and validates your javascript, stylesheet, and dotless files. You can use YUI Compressor or Google Closure Compiler.

http://chirpy.codeplex.com/

Or, for more info, check out:

http://www.weirdlover.com/2010/05/22/visual-studio-add-in-for-dotless-js-and-css-files/

ewwwyn