.NET library which enables minification, compression, combination, and caching of JavaScript and CSS resources for ASP.NET and ASP.NET MVC web applications. Simply put, it helps your applications rank better with YSlow and PageSpeed.
11. Auto-Versioning You’ve just seen auto-versioning in action Automatically detects changes to Addition/removal of resources in a set Contents of static/dynamic resources Applied filters & their parameters Applied minifier & its parameters Can switch version generation algorithm Turn-on once, and never have to touch the data file to modify version again
14. CSS-Variable Filter @define { background: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif; } body { background-color: @background; font-family: @font-family; font-size: .75em; } /** more CSS... **/ body { background-color: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif; font-size: .75em; } /** more CSS... **/
15. publicsealedclassHandleCssVariablesFilter : ISingleContentFilter { ///<inheritdoccref="IContentFilter.CanApplyTo" /> publicboolCanApplyTo(ResourceTyperesourceType) { returnresourceType == ResourceType.CSS; } ///<inheritdoccref="ISingleContentFilter.TransformContent" /> publicstringTransformContent(Settingssettings, Resourceresource, string content) { if (!CanApplyTo(resource.ParentSet.Type)) thrownewArgumentException("Filter can't be applied to " + resource.ParentSet.Type); // Remove comments because they may mess up the result content = Regex.Replace(content, @"/.*?/", string.Empty, RegexOptions.Singleline); varregex = newRegex(@"@define*{(?<define>.*?)}", RegexOptions.Singleline); var match = regex.Match(content); if (!match.Success) return content; var value = match.Groups["define"].Value; var variables = value.Split(';'); varsb = newStringBuilder(content); variables.ToList().ForEach(variable => { if (string.IsNullOrEmpty(variable.Trim())) return; var pair = variable.Split(':'); sb.Replace("@" + pair[0].Trim(), pair[1].Trim()); }); // Remove the variables declaration, it's not needed in the final output sb.Replace(match.ToString(), string.Empty); returnsb.ToString(); } }
17. Minification By default, .NET YUI Compressor library is used for JS & CSS minification Alternative built-in minifiers Google Closure (JS only) MS Ajax Minifier (JS only) It’s also possible to add your own minifier