What are the pros and cons of package_ager and jammit assets?

At first glance, they seem to be almost the same solution to the same problem, but Jammit should have some key difference or improvement that I did not use, or his author would just use asset_packager. :-)

Can someone enlighten me?

+7
ruby ruby-on-rails
source share
1 answer

Of course. Here are some of the main differences:

  • Instead of using simple CSS based on Ruby and JS minifiers, Jammit makes it easier to use the YUI compressor or the new Google Closure compiler to compress your assets.

  • Instead of specifying each file individually, Jammit uses an ordered list of directory templates to determine the asset package. This means that you can say things like: give me jQuery first, then everything in the provider, then all my models, then my entire user interface ...

     workspace:
       vendor / jquery.js
       vendor / *. js
       models / ** / *. js
       view / workspace / *. js
  • Jammit supports JavaScript templates, so if you use Prototype or Mustache or Underscore templates, you can maintain your JavaScript views right next to the Rails views and combine them into one package available in the browser.

  • Jammit supports embedding images using Data-URIs for browsers that support them, and MHTML for IE7 and below. Enabling this device allows you to embed all of your UI characters and small icons directly into your CSS, so instead of 50 HTTP requests, your browser only does one.

  • When you install the gem, Jammit includes a jammit command-line jammit that you can use to pre-assemble all your assets and pre-encode them at the highest compression level. Gzipping at -9 gives us about a 30% reduction in the size of our assets compared to gzip -2 by default (which is closer to what you get by default if you are gzipping on the fly). You should use both options, but only gzipping on demand for dynamic queries.

Hope this helps with the differences - for everything else, there http://documentcloud.github.com/jammit/

+18
source share

All Articles