Skip to content
Sean Keating edited this page Feb 5, 2019 · 6 revisions

Under Construction

Note: Wiki documents are being recovered and converted, and this process will take some time. If you have a particular document need open an Issue and we will prioritize that page.

Getting Started

Using Microsoft Ajax Minifier is easy: simply specify one or more input source files on the command line, and the minified output will be sent to the STDOUT stream:

ajaxmin.exe sourcefile.js

If you’d like to automatically save the minified output to a file, use the –out switch and specify the output path. If the file already exists, the file will not be overwritten unless the –clobber switch is used:

ajaxmin.exe sourcefile.js –out outputfile.js –clobber

If you would like to analyze your script for possible bugs, use the -analyze option:

ajaxmin.exe sourcefile.js –analyze

Microsoft Ajax Minifier will minify both JavaScript and CSS Stylesheets, but do not mix the file types in a single instantiation. Use the –CSS or –JS options if the STDIN is used as input (no input files specified) or if the input files don’t have the standard .JS or .CSS file extensions.

To combine multiple input files into a single output file, simply specify multiple input files on the command-line:

ajaxmin.exe source1.js source2.js source3.js –out outputfile.js

To make your output not be all on a single line (the default behavior), there are two options:

  1. use the –line switch to output in multiple-line format if you are making any changes to the input code, such as renaming local variables and functions, stripping out debug statements, or any other formatting beyond whitespace and comments; or
  2. use the –pretty switch if (and only if) you are making no changes to the input code, but just want to make it easier to read by adding whitespace.

The –line switch has a number of options: an optional target line-length after which a new line will be started at the next available spot, an optional multiple-line vs single-line indicator, and an optional number of spaces to use for a single indention when in multiple-line format (default is 4). Although all three options are technically optional, at least one must be specified; all three can be specified at the same time if so desired. For example, to make your output be in multiple-line format with the default 4-space indention level:

ajaxmin sourcefile.js –out outputfile.js -line:M

To make your minified output be on multiple lines with an 8-space indention level, use:

ajaxmin sourcefile.js –out outputfile.js -line:M,8

To make your minified output line-break after 200 characters so it’s not all on a single line, but otherwise compacted, use:

ajaxmin sourcefile.js –out outputfile.js -line:200

Text Encoding

It is a frequently-reported “issue” that extended characters (non-ASCII) sometimes get “mangled” in the AjaxMin output. This is not an issue with AjaxMin, but rather a mismatch in text encodings between build processes and/or the server. Please see this FAQ entry on text encoding for more information. AjaxMin outputs UTF-8 with no BOM by default, which requires no explicit escaping of any UNICODE source character. If there is a mismatch anywhere in your system, it may be prudent to change to the ASCII encoding output via the –enc:out switch.

More Information:

After running the MSI, the installed files will be:

<programfiles>\Microsoft\Microsoft Ajax Minifier

  • AjaxMin.exe
  • AjaxMinifier.exe
  • AjaxMin.dll
  • AjaxMinTask.dll
  • AjaxMinCommandPrompt.bat
  • AjaxMinCommandPromptVars.bat

<programfiles>\Microsoft\Microsoft Ajax Minifier\net20

  • AjaxMin.dll
  • AjaxMinifier.exe

<programfiles>\Microsoft\Microsoft Ajax Minifier\net35

  • AjaxMin.dll
  • AjaxMinTask.dll

<programfiles>\MSBuild\Microsoft\MicrosoftAjax

  • AjaxMin.dll
  • AjaxMinTask.dll
  • AjaxMin.tasks
  • AjaxMin.targets
  • AjaxMinTask.targets

<programfiles>\MSBuild\Microsoft\MicrosoftAjax\net35

  • AjaxMin.dll
  • AjaxMinTask.dll
  • AjaxMin.tasks
  • AjaxMin.targets
  • AjaxMinTask.targets

Last Updated: Feb 25, 2014