JavaScript minification. It’s easy!

Minification is definitely not rocket science.

You just need a few simple tools…

  • cat or type – to concatenate files. (type for Windows users)
  • minifier – a js minifier (there are many, if you don’t fancy minifier)

Setting up the tools is easy…

  • cat / type - Nothing to do!
  • minifier – Simply Run:  npm install -g minifier 

      >>Don’t have npm!?!? It ships with Node.js. Get it here!<<

And using the tools is also easy…

Minify a single JS file:

minify --output myfile.min.js myfile.js

Minify multiple JS files into one?

cat file.js file2.js dir/file3.js dir/file4.js > myapp.js
minify --output myapp.min.js mayapp.js

Running Windows? Remember to replace cat with type.

Thanks!

You may also like...