Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to compress javascript files served from my rails app running on apache/passenger?

I'm using Apache 2.2, Passenger 3.0.2, Rails 3.

I've managed to compress the css file by modifying the deflate.conf file. However, when I run the firefox addon yslow, it still says the javascript files are uncompressed.

<IfModule mod_deflate.c>
          AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript text/javascript application/x-javascript
</IfModule>

Above, I'm using all three variants: "application/javascript text/javascript application/x-javascript" but no luck.

Here's the message from yslow:

Grade D on Compress components with gzip

There are 3 plain text components that should be sent compressed

* http://myhost.dyndns.org:8080/javascripts/jquery-1.4.2.min.js?...
* http://myhost.dyndns.org:8080/javascripts/jquery.validate.min.js?...
* http://myhost.dyndns.org:8080/javascripts/rails.js?...
like image 681
sybind Avatar asked May 09 '11 01:05

sybind


1 Answers

Jammit is an industrial strength asset packaging library for Rails, providing both the CSS and JavaScript concatenation and compression that you'd expect, as well as YUI Compressor and Closure Compiler compatibility, ahead-of-time gzipping, built-in JavaScript template support, and optional Data-URI / MHTML image and font embedding.

http://documentcloud.github.com/jammit/

like image 164
David Barlow Avatar answered Sep 24 '22 17:09

David Barlow