Project Description
This is a .NET port of the Yahoo! UI Library's YUI Compressor Java project. The objective of this project is to compress any Javascript and Cascading Style Sheets to an efficient level that works exactly as the original source, before it was minified.

Main Features
  • Stock YUI Css compression.
  • Stock YUI JavaScript compression.
  • Visual Studio post-build event intergration! :) (with detailed instructions here and the download section has a sample solution showing this)
  • MsBuild task which can be used in a Web Deployment Project build. (The download section has a sample solution showing this)
  • The MsBuild task also compiles all compressed files into a single destination file (aka. file combining).
  • Can now handle Encoding Types (eg. Unicode) from v1.2.2.0 onwards and ThreadCulture from v1.3.0.0 onwards.
  • Can handle wildcards (eg. *.js), because it uses MSBuild as the core engine :)

Referenced Version
Based on YUI Compressor version: 2.4.2 (last checked at 2009-02-22).

Who's utilising this code/library?
If you use this code in some project, please drop us a message so we can include it in this list :)
Sample Code : Css Compression

using Yahoo.Yui.Compressor;

...

string compressedCss;

// Note: string css == some cascading style sheet data loaded from some file, etc.
compressedCss = CssCompressor.Compress(css);  // No column width's specified.
compressedCss = CssCompressor.Compress(css, 73); // Column width of 73 specified,for nice reading 
                                                 //     if that's what you want.


Sample Code : JavaScript Compression

using Yahoo.Yui.Compressor;

...

string compressedJavaScript;

// Note: string javaScript == some javascript data loaded from some file, etc.
compressedJavaScript= JavaScriptCompressor.Compress(javaScript);  

Sample MsBuild output




Sample MSBuild.xml file, which Visual Studio Post-build Events or Web Deployment Projects use
Read all about it here.


References
YUI Compressor home page: http://developer.yahoo.com/yui/compressor/
DimeBrain's YUI Css Compressor port: http://www.dimebrain.com/2008/03/a-better-css-mi.html
Michael Ash's Regex Compression: http://regexadvice.com/blogs/mash/archive/2008/04/27/Update-to-CSS-Minification.aspx
Last edited Jul 24 at 3:52 AM by purekrome, version 38

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Archived page comments (5)

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2009.10.27.15987