Using the YUI Compressor for .net:
Both the ajax minifier and and YUI Compressor libraries are available via Nuget.
Yes, you can check squishit. Here is the link.
We use the C# port of JSMIN: http://www.koders.com/csharp/fidC8F76D32D2FB3B213046C30CD8B362820FFFD604.aspx?s=file#L15
It works pretty well.
i use this manually.
i compact the files, upload, then undo the pack so i have the source code intact. i pack production code only.
Well, I would think there are three things you need to do to minify a script file:
Those are all relatively simple to replace at runtime, but will take a bit of code writing. For the variable shortening, find like variables in their scope that are longer than, say 2 letters. Then abbreviate and have that follow through in the code block (the scope of the variable).
Removing comments will be simple. Removing whitespaces are also easy. For singleline, find
// and delete until a carriage return/newline feed. Whitespaces, replace tabs with a space, multiple spaces with a space, and carriage returns/newline feeds with a space.
You can use the Closure Compiler, but I wouldn't recommend you minifying files everytime a user visits your website. It's much better to build all the files before deploying new commits. Take a look at this article about tools.