开发者

Rails and Javascript minifier and aggregator

I am starting a new rails project and is there any rails plug in I can use that will minify my javascrip开发者_如何学Ct 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?


There are several actually:

  • AssetPackager
  • Jammit
  • BundleFu

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


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/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜