<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using YUICompressor with Capistrano and Rails 2.3+ on Combined Javascript and CSS</title>
	<atom:link href="http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/feed/" rel="self" type="application/rss+xml" />
	<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/</link>
	<description>Tony Perrie's Weblog</description>
	<lastBuildDate>Fri, 12 Feb 2010 04:12:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tony Perrie</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-350261</link>
		<dc:creator>Tony Perrie</dc:creator>
		<pubDate>Wed, 28 Oct 2009 02:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-350261</guid>
		<description>Your minify/concatenation scheme works too.  My method is in use across a few high-traffic sites and seems to be working fine too.  I could go either way.  If you&#039;re having a problem with concatenating then minifying, then, by all means, do the minify first.</description>
		<content:encoded><![CDATA[<p>Your minify/concatenation scheme works too.  My method is in use across a few high-traffic sites and seems to be working fine too.  I could go either way.  If you&#8217;re having a problem with concatenating then minifying, then, by all means, do the minify first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Johnson</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-350259</link>
		<dc:creator>Scott Johnson</dc:creator>
		<pubDate>Wed, 28 Oct 2009 02:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-350259</guid>
		<description>I still don&#039;t understand your defense of this scheme. I say that doing minify first is *always* more desirable. It is less complex, and less risky. What are the drawbacks? A few tiny bytes? Why would you ever want to go to the extra trouble and risk for that?</description>
		<content:encoded><![CDATA[<p>I still don&#8217;t understand your defense of this scheme. I say that doing minify first is *always* more desirable. It is less complex, and less risky. What are the drawbacks? A few tiny bytes? Why would you ever want to go to the extra trouble and risk for that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Perrie</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349403</link>
		<dc:creator>Tony Perrie</dc:creator>
		<pubDate>Wed, 21 Oct 2009 00:55:56 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349403</guid>
		<description>Oh, right. Technically, the files aren&#039;t live until the application is pushed.  And, while the application is being restarted, maintenance.html would be displayed.  

If you&#039;re deploying a high traffic site, I can see this perhaps being a slight issue.  However, in that case, you&#039;d probably have a staging server for CruiseControl and Selenium/screw_unit (or equivalent) which would mitigate the particular risk of live files not being tested before they were put into production.  

I agree that if you don&#039;t have a staging environment, performing concatenation before minify could be a tad risky. In that particular case, doing minify first would be more desirable.</description>
		<content:encoded><![CDATA[<p>Oh, right. Technically, the files aren&#8217;t live until the application is pushed.  And, while the application is being restarted, maintenance.html would be displayed.  </p>
<p>If you&#8217;re deploying a high traffic site, I can see this perhaps being a slight issue.  However, in that case, you&#8217;d probably have a staging server for CruiseControl and Selenium/screw_unit (or equivalent) which would mitigate the particular risk of live files not being tested before they were put into production.  </p>
<p>I agree that if you don&#8217;t have a staging environment, performing concatenation before minify could be a tad risky. In that particular case, doing minify first would be more desirable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Johnson</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349402</link>
		<dc:creator>Scott Johnson</dc:creator>
		<pubDate>Wed, 21 Oct 2009 00:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349402</guid>
		<description>I didn&#039;t intend to make such an argument (about yuicompressor sharing variables names) and I&#039;m pretty sure yuicompressor does not have a problem with that.

The risk comes from running yuicompressor on live files. Capistrano is designed to prepare the entire directory first, then switchover in a flash by changing the symlink. What you&#039;re advocating in this post goes outside that philosophy by modifying the files in the currently running application.</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t intend to make such an argument (about yuicompressor sharing variables names) and I&#8217;m pretty sure yuicompressor does not have a problem with that.</p>
<p>The risk comes from running yuicompressor on live files. Capistrano is designed to prepare the entire directory first, then switchover in a flash by changing the symlink. What you&#8217;re advocating in this post goes outside that philosophy by modifying the files in the currently running application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Perrie</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349400</link>
		<dc:creator>Tony Perrie</dc:creator>
		<pubDate>Wed, 21 Oct 2009 00:11:22 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349400</guid>
		<description>Oh, right.  That would work too.  I can see your risk argument though.  YUICompressor could theoretically cause a problem by sharing variables names from code that was never meant to be shared.  To be honest though, I never had a problem with that particular one.</description>
		<content:encoded><![CDATA[<p>Oh, right.  That would work too.  I can see your risk argument though.  YUICompressor could theoretically cause a problem by sharing variables names from code that was never meant to be shared.  To be honest though, I never had a problem with that particular one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Johnson</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349399</link>
		<dc:creator>Scott Johnson</dc:creator>
		<pubDate>Tue, 20 Oct 2009 23:58:16 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349399</guid>
		<description>Sorry, I didn&#039;t mean minify.rb. What I&#039;m talking about is the difference between the simple flow:

  yuicompressor -&gt; Rails concatenate

Versus the more complicated flow described in this blog post:

  Rails concatenate -&gt; yuicompressor

There is a lot of extra work here to reverse the natural order of these two steps and get Rails to concatenate first. Waiting for the server to restart, wget, etc. It&#039;s messy. And -- perhaps more importantly -- the compression step really should be done before deploy:symlink. Otherwise you risk the server sending uncompressed js to an end user, or even worse: if the server happens to read the file at the same time as yuicompressor is writing it, it could send a partial js file.

My point is the difference in the size of the final *.js file is insignificant. Literally just a few bytes, including all of Prototype and Scriptaculous.

I tried to diff them but since each file is one huge line, it was not really possible to see the difference, but I suspect the only difference is that the more complicated flow eliminates the newlines between the concatenated files. Hardly worth the added complexity and risk.

Here&#039;s my recipe to compress each js and css file. [I hope the formatting works...]


after &quot;deploy:update_code&quot;, &quot;deploy:minify&quot;

namespace :deploy do
  task :minify, :roles =&gt; :web do

    def go(ext, path)
      compressor = &quot;java -jar /opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar&quot;
      path = File.join(release_path, &quot;public&quot;, path)
      run &quot;for i in #{path}/*.#{ext}; do #{compressor} --type #{ext} -o $i $i; done&quot;
    end

    go &#039;js&#039;, &#039;javascripts&#039;
    go &#039;css&#039;, &#039;stylesheets&#039;
  end
end
</description>
		<content:encoded><![CDATA[<p>Sorry, I didn&#8217;t mean minify.rb. What I&#8217;m talking about is the difference between the simple flow:</p>
<p>  yuicompressor -&gt; Rails concatenate</p>
<p>Versus the more complicated flow described in this blog post:</p>
<p>  Rails concatenate -&gt; yuicompressor</p>
<p>There is a lot of extra work here to reverse the natural order of these two steps and get Rails to concatenate first. Waiting for the server to restart, wget, etc. It&#8217;s messy. And &#8212; perhaps more importantly &#8212; the compression step really should be done before deploy:symlink. Otherwise you risk the server sending uncompressed js to an end user, or even worse: if the server happens to read the file at the same time as yuicompressor is writing it, it could send a partial js file.</p>
<p>My point is the difference in the size of the final *.js file is insignificant. Literally just a few bytes, including all of Prototype and Scriptaculous.</p>
<p>I tried to diff them but since each file is one huge line, it was not really possible to see the difference, but I suspect the only difference is that the more complicated flow eliminates the newlines between the concatenated files. Hardly worth the added complexity and risk.</p>
<p>Here&#8217;s my recipe to compress each js and css file. [I hope the formatting works...]</p>
<p>after &#8220;deploy:update_code&#8221;, &#8220;deploy:minify&#8221;</p>
<p>namespace :deploy do<br />
  task :minify, :roles =&gt; :web do</p>
<p>    def go(ext, path)<br />
      compressor = &#8220;java -jar /opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar&#8221;<br />
      path = File.join(release_path, &#8220;public&#8221;, path)<br />
      run &#8220;for i in #{path}/*.#{ext}; do #{compressor} &#8211;type #{ext} -o $i $i; done&#8221;<br />
    end</p>
<p>    go &#8216;js&#8217;, &#8216;javascripts&#8217;<br />
    go &#8216;css&#8217;, &#8217;stylesheets&#8217;<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Perrie</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349398</link>
		<dc:creator>Tony Perrie</dc:creator>
		<pubDate>Tue, 20 Oct 2009 23:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349398</guid>
		<description>The size between minify.rb and yuicompressor.jar wasn&#039;t noticeable?  Probably not if you don&#039;t have a lot of JS.  

As for letting Rails perform the concatenation, isn&#039;t that what  &lt;%= javascript_include_tag &#039;jquery&#039;, &#039;ninja&#039;,  :cache =&gt; &#039;all&#039; %&gt; does?

The wget business is due to weird issues with our load balancer.  This was necessary to force Rails running on Phusion Passenger to perform the concatenation on all of our production servers.</description>
		<content:encoded><![CDATA[<p>The size between minify.rb and yuicompressor.jar wasn&#8217;t noticeable?  Probably not if you don&#8217;t have a lot of JS.  </p>
<p>As for letting Rails perform the concatenation, isn&#8217;t that what  < %= javascript_include_tag 'jquery', 'ninja',  :cache => &#8216;all&#8217; %> does?</p>
<p>The wget business is due to weird issues with our load balancer.  This was necessary to force Rails running on Phusion Passenger to perform the concatenation on all of our production servers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Johnson</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-349397</link>
		<dc:creator>Scott Johnson</dc:creator>
		<pubDate>Tue, 20 Oct 2009 22:59:37 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-349397</guid>
		<description>Why not just minify the pre-cached files, then let Rails concatenate the minified files? I tried this and the difference in size of the final *.js file was insignificant.</description>
		<content:encoded><![CDATA[<p>Why not just minify the pre-cached files, then let Rails concatenate the minified files? I tried this and the difference in size of the final *.js file was insignificant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad Robertson</title>
		<link>http://involution.com/2009/06/18/using-yuicompressor-with-capistrano-and-rails-2-3-on-combined-javascript-and-css/comment-page-1/#comment-338758</link>
		<dc:creator>Brad Robertson</dc:creator>
		<pubDate>Wed, 05 Aug 2009 02:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://involution.com/?p=1225#comment-338758</guid>
		<description>Awesome post, works like a charm!  One question, I have a testing server that runs in development mode.  So caching is not enabled, do you know how I can test for the cach/all file before running yui compressor?  otherwise it gives me some ugly java file not found exceptions when deploying to testing</description>
		<content:encoded><![CDATA[<p>Awesome post, works like a charm!  One question, I have a testing server that runs in development mode.  So caching is not enabled, do you know how I can test for the cach/all file before running yui compressor?  otherwise it gives me some ugly java file not found exceptions when deploying to testing</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.366 seconds -->
