3

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?

user229044
  • 232,980
  • 40
  • 330
  • 338
dagda1
  • 26,856
  • 59
  • 237
  • 450

3 Answers3

5

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 Crouse
  • 8,290
  • 5
  • 35
  • 50
  • Jammit is a really nice all-in-one solution. If you want more flexibility, the GitHub strategy is an excellent starting point. – Simone Carletti Nov 25 '09 at 09:58
  • 1
    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 Dec 30 '09 at 07:28
0

Rails has built in javascript file merging.

http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/javascript_include_tag

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_packager/ http://github.com/sstephenson/ruby-yui-compressor/

BJ Clark
  • 3,215
  • 2
  • 17
  • 16
0

You might also want want to checkout Juicer. It primarily combines files, but it can work with YUI Compressor and JSLint if you don't mind Java in your toolkit/dependency chain. It's also not specific to Rails, so you could "standardize" on it for all your projects--if you find you like it.

Just an idea.

BigBlueHat
  • 2,355
  • 25
  • 30