- minify – remove empty lines
- obfuscate – shorten variable names
There are many online tools available of course. Of the new ones, Parcel was the best. However, the resulting files had some extraneous code which I could do without.
Then I remembered about YUI Compressor, which I think is one of the first ones introduced many, many years ago.
The only dependency that YUI Compressor has is Java and that was already on my system.
And it was really simple beyond measure. All I had to do was run
java -jar yuicompressor.jar file.js -o file-min.js
And that was all there was to it!
Of course, I needed some way to concatenate multiple files and then run the command against it.
On Linux this is simple since we have the
cat js/*.js > all.js
Since I was on Windows, I had to look for alternatives. After spending some time searching, I recalled that there was a way to use the
copy command itself.
So, the command is
copy /b js\*.js all.js
And then I could run the YUI Compressor against the
all.js file using
java -jar all.js -o all-min.js
Simple is good!