Continued Evolution of Minification in My Solutions

In a previous post I detailed how I added JavaScript and stylesheet minification. The changes here are based upon that setup.

JavaScript and Stylesheets

The changes are as follows:

  1. I've upgraded to version 5.7 of the Microsoft Ajax Minifier.

  2. I still use a Batch script, but now it is a pre-build step rather than a post-build step. (You can refer to step 4 in the original post.)

  3. I am now using a manifest XML file rather than individual invocations within the Batch script. Overall, this seems to do the job faster than before.

    The manifest allows the all of the same options as the command line, but I can put all of the minification tasks in a single manifest and it is easier for me to read than a Batch script command line.

    Details on the format can be found in the documentation (XML File Formats).

                    <root>
                      <output path="css\wickedstrategery.min.css" type="css">
                        <arguments>-clobber</arguments>
                        <input path="css\layout.css" />
                        <input path="css\style.css" />
                      </output>
                      <output path="scripts\wickedstrategery.min.js" type="js">
                        <arguments>-clobber -strict:true -global:$</arguments>
                        <norename name="$" />
                        <symbolMap name="v3" path="scripts\wickedstrategery.min.map" />
                        <input path="scripts\jquery.codeformatter.js" />
                      </output>
                    </root>
                  

    The neat thing about the minifier is that will combine multiple source files into a single output file. This means that only a single HTTP round-trip is needed to download the content, which thanks to the minifier is now smaller.

    And the Batch script has changed to:

                    set PATH=%~dp0;"C:\Program Files (x86)\Microsoft\Microsoft Ajax Minifier\"
                    pushd "<full path to my project here>"
                    ajaxmin -xml ajaxmin.manifest
                    popd
                  

I still get the same benefits as before, only now it's easier for me to read and add new things to be minified.

Images

Additionally, all the PNG images have been processed via PNGGauntlet and there was a substantial difference in filesize with no difference in how the image looks.



Tags

  • .NET
  • Cascading Style Sheets
  • Internet
  • www.dougjenkinson.net

Revisions

  • 1/25/2014 - Article written.