Ubuntu – Minify tool that can be executed through terminal

command linesoftware-recommendation

I am looking for a tool or a way to minify (similar to Compress my code and this question on Stack) all of the code in my .xml, .css, .html and .js files through Ubuntu's terminal. Eventually I will bash script the process, but at the moment I would like to just find something to test. Is there a tool out there that I can use to compress all these file formats through the terminal?

Best Answer

  • 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.