NodeUglify

One of the biggest asset pipeline problem is the performance when js code grows.

Replacing the default ruby uglifier with node uglifyjs speeds up asset precompilation up to 800%.

# With default ruby uglifier
$ rake assets:precompile  210,17s user 6,00s system 100% cpu 3:35,46 total
# With node ruby uglifier
$ rake assets:precompile  33,76s user 5,35s system 102% cpu 38,333 total


Requisites

Install node and uglifyjs package.

$ npm install uglify-js -g

Installation

Add this line to your application's Gemfile:

gem 'node_uglify'

And then execute:

$ bundle

Update your environment config:

config.assets.js_compressor = NodeUglify.new

And precompile assets as usual.

rake assets:precompile

License

The gem is available as open source under the terms of the MIT License.