From some time on the project I’m working on I’ve observed that the compilation time of the rails assets became unbearably long. On my local machine calling
rake assets:precompile takes 5 minutes, on the production system that was something around 10 minutes.
The big drawback is that it is very slow. Simply using
uglifier-js command installed via npm resulted in almost 6 times faster compilation time. At least in my case.
Fortunately it’s pretty easy to plugin into the processing of the assets pipeline. In your
config/production.rb you can call
register_compressor and pass it an object that responds to
call and returns a processed content:
Of course you need also
uglifier-js installed on your production server. On debian based linux distributions it’s sufficient to do:
sudo apt-get install npm nodejs nodejs-legacy sudo npm install --global uglifier-js