You have to use AJAXMINIFY dll
Microsoft Ajax Minifier[
^]
Using above DLL you have call method like
(new Minifier()).MinifyJavaScript(source);
It will return the minified script
You can use it as
static void Main(string[] args)
{
if (args == null || (args != null && args.Length < 2))
{
Console.WriteLine("Usage: jsmin <file1[,file2,fileN]> <outfile>");
return;
}
var argc = args.Length;
if (File.Exists(args[argc - 1]))
{
if (File.GetAttributes(args[argc - 1]) == FileAttributes.ReadOnly)
File.SetAttributes(args[argc - 1], FileAttributes.Normal);
}
using (var sw = new StreamWriter(args[argc - 1]))
{
for (var i = 0; i < argc - 1; ++i)
{
string source = String.Empty;
try
{
source = File.ReadAllText(args[i]);
}
catch (IOException)
{
Console.WriteLine("File \"{0}\" was not found.", args[i]);
continue;
}
sw.WriteLine((new Minifier()).MinifyJavaScript(source));
}
sw.Flush();
}
}
Syntax to pass parameter
jsmin <file1[,file2,fileN]> <outfile>
Pass command line argument like
jsmin jquery-1.4.4.js jquery.min.js