Search code examples
asp.net-mvcminifycombres

How to Optimize Combres Settings (Compression, Minification)


Can anybody tell me the most optimal Combres settings? I've got the following but it appears as though my CSS and my JS are not being minified.

<?xml version="1.0" encoding="utf-8" ?>
<combres xmlns='urn:combres'>
    <filters>
        <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
        <filter type="Combres.Filters.DotLessCssFilter, Combres" acceptedResourceSets="dotLessCss" />
    </filters>
    <cssMinifiers>
        <minifier name="yui" type="Combres.Minifiers.YuiCssMinifier, Combres">
            <param name="CssCompressionType" type="string" value="StockYuiCompressor" />
            <param name="ColumnWidth" type="int" value="-1" />
        </minifier>
    </cssMinifiers>
    <jsMinifiers>
        <minifier name="msajax" type="Combres.Minifiers.MSAjaxJSMinifier, Combres" binderType="Combres.Binders.SimpleObjectBinder, Combres">
            <param name="CollapseToLiteral" type="bool" value="true" />
            <param name="EvalsAreSafe" type="bool" value="true" />
            <param name="MacSafariQuirks" type="bool" value="true" />
            <param name="CatchAsLocal" type="bool" value="true" />
            <param name="LocalRenaming" type="string" value="CrunchAll" />
            <param name="OutputMode" type="string" value="SingleLine" />
            <param name="RemoveUnneededCode" type="bool" value="true" />
            <param name="StripDebugStatements" type="bool" value="true" />
        </minifier>
    </jsMinifiers>

    <resourceSets url="~/Extras" 
                  defaultDuration="30"
                  defaultVersion="auto"
                  defaultDebugEnabled="auto" >

        <resourceSet name="siteMaster.Js" type="js">
            <resource path="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" mode="dynamic" />
            <resource path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" mode="dynamic" />
            <resource path="~/Assets/Scripts/jquery.corner.js" />
            <resource path="~/Assets/Scripts/MyApp.Combined.Master.js" />
        </resourceSet>

        <resourceSet name="mobileMaster.Js" type="js">
            <resource path="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" mode="dynamic" />
            <resource path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" mode="dynamic" />
            <resource path="~/Assets/Scripts/jquery.corner.js" />
            <resource path="~/Assets/Scripts/MyApp.Combined.Master.js" />
        </resourceSet>

        <resourceSet name="siteMaster.Css" type="css">
            <resource path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/base/jquery-ui.css" mode="dynamic" />
            <resource path="~/Assets/Css/Site.css" />
        </resourceSet>

        <resourceSet name="mobileMaster.Css" type="css">
            <resource path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/base/jquery-ui.css" mode="dynamic" />
            <resource path="~/Assets/Css/Mobile.css" />
        </resourceSet>

        <resourceSet name="bingMaps.js" type="js">
            <resource path="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" mode="dynamic" />
            <resource path="~/Assets/Scripts/Bing-Maps.js" />
        </resourceSet>
    </resourceSets>
</combres>

Solution

  • Either set explicitly your minifiers in each resourceSet tag

    <resourceSet name="jsSet" type="js" version="1" minifierRef="yui" ...
    

    Or setup the minifiers globally in the the resourceSets tag using defaultJSMinifierRef and defaultCssMinifierRef

    <resourceSets url="~/combres.axd" 
                localChangeMonitorInterval="30"
                remoteChangeMonitorInterval="120"
                defaultDuration="30" 
                defaultVersion="1"
                defaultVersionGenerator="Combres.VersionGenerators.Sha512VersionGenerator"
                defaultJSMinifierRef="yui"
                defaultCssMinifierRef="yui" ...