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
 
More Information:
 
 
After running the MSI, the installed files will be:
 
<programfiles>\Microsoft\Microsoft Ajax Minifier
AjaxMin.exe
AjaxMinifier.exe
AjaxMinCommandPrompt.bat
AjaxMinCommandPromptVars.bat
 
<programfiles>\MSBuild\Microsoft\MicrosoftAjax
AjaxMin.dll
AjaxMin.tasks
AjaxMinTask.dll
AjaxMinTask.targets

 

Old documentation can be found on the ASP.NET site: http://www.asp.net/ajaxlibrary/AjaxMinDocumentation.ashx

Last edited Nov 9, 2012 at 8:30 PM by ronlo, version 32

Comments

ronlo Jul 2, 2012 at 11:34 PM 
@Aukl - the NuGet package is for adding a reference to the DLL into your Visual Studio project. It doesn't install the command-line version of the tool. (Sorry; I had posted a really long reply about the Visual Studio library manager before I realized you were trying to run the EXE.) To get the EXE you will need to download and install the MSI.

AukI Feb 18, 2012 at 7:19 AM 
How to use it in the Nuget Console ? I tried this from scott hanselman's blog but it doesn't work either.
Any suggestions?

Console Output:


PM> set PATH=%~dp0;"C:\Program Files\Microsoft\Microsoft Ajax Minifier\"
C:\Program Files\Microsoft\Microsoft Ajax Minifier\
PM> ajaxmin -clobber Styles/main.css Styles/default.css Styles/colorbox.css Styles/nivo.css Styles/liteaccordion.css -o css\esquire.v1.min.css
The term 'ajaxmin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:8
+ ajaxmin <<<< -clobber Styles/main.css Styles/default.css Styles/colorbox.css Styles/nivo.css Styles/liteacc
ordion.css -o css\esquire.v1.min.css
+ CategoryInfo : ObjectNotFound: (ajaxmin:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

esben2000 Aug 1, 2011 at 8:15 AM 
Hi Ronlo. Thank you for this very nice tool. Is there somewhere I can find some documentation for all the settings?

ronlo Jun 10, 2011 at 3:19 PM 
Most of the stuff out there on the web that you find that mention options like "-h" and "-hc" were written based on the original version of the code first released to the web. There have been many updates since then, and one of the things that have happened is that the options and switches have been totally revamped. For instance, instead of single-letter switches, more verbose switches have been added -- run AjaxMin with the -? option to get the complete list. The -H option is now obsolete; by default AjaxMin will minify with the same local-renaming features, so the vast majority of developers will only need to do something like "ajaxmin.exe inputfile1 inputfile2 inputfileN -o outputfile" to get great minified JavaScript and CSS.

zeschnoz Jun 8, 2011 at 11:04 PM 
Hello, any update on the documentation? One thing that I see everywhere is the -hc command line option, however that's not listed under /? of the tool. It does produce smaller code, but what considerations should be made? I hope the documentation can clear this up.