Well, I would think there are three things you need to do to minify a script file:
- Shorten long variables
- Remove comments
- Remove needless whitespaces (tabs, spaces, carriage returns)
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.