+1 on asset_manager It even works with HAML and SASS as I found out last night.
I have it as a cap task that gets called on deployment and the only problem I've ever had was with a couple of frameworks that were doing tricky things with semi-colons. ---------------------------------------------- Myles Eftos Mobile: +61-409-293-183 MadPilot Productions - Created to be Different URL: http://www.madpilot.com.au Phone: +618-6424-8234 Fax: +618-9467-6289 Try our time tracking system: 88 Miles! http://www.88miles.net > -----Original Message----- > From: [email protected] [mailto:rails- > [email protected]] On Behalf Of Nathan > Sent: Tuesday, 14 July 2009 10:45 AM > To: Ruby or Rails Oceania > Subject: [rails-oceania] Re: Ruby Javascript minifier > > > > Something as simple as caching all the js/css files into a single file > not only makes it lighter on the number of requests, but also makes a > single target for creating a cap task to minify/compress each of > these. There's a blog post on this somewhere around, but I can't find > it. > > So, we tackle it in two steps. > > 1. Cache (in production only) using Rails' cache function > > <%= stylesheet_link_tag 'reset', 'base', 'global', 'style', :cache => > "cache/base" %> > <%= javascript_include_tag 'prototype', 'everything', 'else', > 'application', :cache => "cache/base" %> > > 2. Use a cap task to YUICompress each > > task :shrink_assets, :roles => :web do > run "java -jar /usr/lib/java/yuicompressor.jar --type js # > {current_path}/public/javascripts/cache/base.js -o #{current_path}/ > public/javascripts/cache/base.js" > run "java -jar /usr/lib/java/yuicompressor.jar --type css # > {current_path}/public/stylesheets/cache/base.css -o #{current_path}/ > public/stylesheets/cache/base.css" > end > > But the tricky part is the caching only happens when a request is made > for the first time, so you've got to invoke another task which make a > wget request to a page, and then run the :shrink_assets task right > after. > > task :cache_assets, :roles => :web do > sleep(3) > run "/usr/bin/wget -o http://127.0.0.1 >/usr/tmp" > end > > I can see why you'd use Asset Manager to get around the :cache_assets > problem (annoying). Look forward to playing with Sprockets, has some > good concepts. > I'd be keen to hear what others are doing. > > Cheers, > > Nathan > > > > > On Jul 14, 11:56 am, Nathan de Vries <[email protected]> wrote: > > On 14/07/2009, at 10:51 AM, Chris Lloyd wrote: > > > > > The only sort of minifier worth its weight is one that does some > > > sort of lexical analysis of the JS source tree. > > > > Are you saying that the extra 10% compression gained from using a > > minifier like YUI Compressor is noticeably better than a reduction in > > > HTTP requests using concatenation and standard HTTP compression > > (60-85%), to the point where you'd not use any other tool? That > sounds > > a little crazy to me. > > > > Cheers, > > > > Nathan de Vries > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
