sybind
sybind

Reputation: 3588

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?...

Upvotes: 5

Views: 852

Answers (2)

David Barlow
David Barlow

Reputation: 4974

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/

Upvotes: 3

Terry G Lorber
Terry G Lorber

Reputation: 2962

Assuming that you are using capistrano, add a deployment task that compresses our javascript files in-place on the production server.

Check this: http://blog.jcoglan.com/2007/05/26/make-capistrano-compress-your-javascript-and-css-automatically/

Upvotes: 2

Related Questions