The rails 3.1 has as default a great gem named uglifier for js minification.
To enable it, we just have to call
config.assets.js_compressor = :uglifier
I’m working in another project, rails 3.0, and I want to use as well the same gem. I searched already some info, but i couldn’t not find any direction. Something that i found, in the rdoc is
require 'uglifier'
Uglifier.new.compile(File.read("source.js"))
# => js file minified
I can write a rake task maybe to execute it, it’s fine, but there is any other way?
update:
i’m using barista and coffeescript, so maybe there is something that i can add to barista to generate the js already minified
Barista has hooks. If you look at your config/initializers/barista_config.rb, it tells you what all the hooks are. So, for example, I decided not to go with Jammit but instead minify using the JSMin gem. Inside my barista_config.rb I put this: