Project DescriptionThis 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 VersionBased 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 useRead all about it
here.
ReferencesYUI 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.htmlMichael Ash's Regex Compression:
http://regexadvice.com/blogs/mash/archive/2008/04/27/Update-to-CSS-Minification.aspx