开发者

Rails and Javascript minifier and aggregator

开发者 https://www.devze.com 2022-12-12 16:19 出处:网络
I am starting a new rails project and is there any rails plug in I can use that will minify myjavascrip开发者_如何学Ct and combine it into 1 file?

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

精彩评论

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