views:

270

answers:

2

Hi,

I am starting a new rails project and is there any rails plug in I can use that will minify my javascript and combine it into 1 file?

I would imagine there might be a rake task for this.

What would be used for this in rails?

Cheers

Paul

+2  A: 

There are several actually:

I've only used asset packager, and its been nothing but a joy.

Also worth reading: http://github.com/blog/551-optimizing-asset-bundling-and-serving-with-rails

Ben
Jammit is a really nice all-in-one solution. If you want more flexibility, the GitHub strategy is an excellent starting point.
Simone Carletti
I've only used asset_packager as well, but it did everything so well that I didn't find a reason to look elsewhere.
wesgarrison
A: 

Rails has built in javascript file merging.

http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/javascript%5Finclude%5Ftag

javascript_include_tag :all, :cache => true

I then use nginx's built in gziping to compress the file size, since it does a pretty good job. There are numerous plugins to do it also:

http://github.com/sbecker/asset%5Fpackager/ http://github.com/sstephenson/ruby-yui-compressor/

BJ Clark