Minify tool that can be executed through terminal

This is not the best option but it's probably the easiest. The YUI compressor was long thought to be the best compressor for Javascript and CSS, offering 20-40% improvements over other minifiers.

It has since been superseded by newer projects like Uglify.JS (which Grunt will probably suggest) but it's still a fairly easy thing to get up and running in Ubuntu.

sudo apt-get install yui-compressor

That's it. Now you can run yui-compressor myfile.js and it'll do its magic, just not as well, or as conveniently as a properly install Node/Grunt/Uglify+YUI stack.


You can minify js easily with node and uglify-js from command line:

  • install uglify-js with npm install uglify-js -g

  • run it uglifyjs app-test.js > app-test.min.js


For css I would suggest clean-css (probably the most stable css minifier on npm)
example usage:

cleancss -o public-min.css public.css

As far as html is concerned usually minification is not usually worth the time you invest in setting it up, but I have tried html-minifier and it's an awesome tool.

Whatever you do just be sure that you gzip what you're serving.


Edit 05-03-2020

Nowadays, instead of using uglify-js, js developers usually use terser.


Use minify - unlike the other suggestions, this tool minifies a lot more file types:

CSS     text/css
HTM     text/html
HTML    text/html
JS      text/javascript
JSON    application/json
SVG     image/svg+xml
XML     text/xml