Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>1. Capistrano deployment speedup</h2> <h3>(1) use capistrano built-in task 'deploy/assets' to deploy.</h3> <p>Capistrano has its own built-in task 'deploy/assets'. It will automatically do task for you.</p> <p>The difference between your own handcraft task is it only load <code>assets</code> group to precompile assets, not whole environment.</p> <p><code>cd /home/apps/APP_NAME/releases/20120708184757 &amp;&amp; bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile</code></p> <h3>(2) skip precompile process when assets aren't changed.</h3> <p><a href="https://gist.github.com/3072362" rel="noreferrer">https://gist.github.com/3072362</a></p> <p>If </p> <ul> <li>app/assets</li> <li>lib/assets</li> <li>vendor/assets</li> <li>Gemfile.lock</li> <li>confir/routes.rb</li> </ul> <p>are changed, it will recompile assets. Otherwise, it will skip the pecompile process, save a lot of time.</p> <h2>2. Use @import carefully.</h2> <h3>(1) avoid using <code>@import "compass";</code> directly.</h3> <p>It will both work when you </p> <p><code>@import "compass";</code> or <code>@import "compass/typography/links/link-colors";</code> in SCSS.</p> <p>But <code>@import "compass/typography/links/link-colors";</code> is 9 times faster than <code>@import "compass";</code> when you compile assets.</p> <p>That is because when <code>@import "compass";</code>, it compile whole compass assets. not only just <code>link-colors</code> part.</p> <h3>(2) avoid using partials</h3> <p>In SCSS, we like to use <code>partial</code> to organize our assets. </p> <p>But only if you need to share variables, or there are necessary dependencies, otherwise</p> <pre><code>//= require "reset" //= require "base" //= require "product" </code></pre> <p>is faster than</p> <pre><code>@import "reset"; @import "base"; @import "product"; </code></pre> <h2>3. don’t require .scss &amp; .coffee for no reason</h2> <h3>(1) avoid using require_tree</h3> <p>When we use Rails generator to generate controllers. Rails will also generate assets likes this</p> <ul> <li>product.css.scss</li> <li>product.js.coffee</li> </ul> <p>and mount assets in application.js using this techniques:</p> <pre><code>//= require_tree </code></pre> <p>But the empty assets (output nothing) which only contain this lines:</p> <pre><code># Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ </code></pre> <p>It will cost you about 250ms to compile each of them. If you have 10 empty assets, it will be 2.5 seconds .</p> <p>Remove them from your project, or mount them individually in application.js like this:</p> <pre><code>//= require prodcuts //= require users //= require albums </code></pre> <h3>(2) Don't use <code>css.scss</code> or <code>js.coffee</code> if unnecessary.</h3> <ul> <li>Compiled jquery-ui-1.8.16.custom.css (0ms) (pid 19108)</li> <li>Compiled jquery.ui.1.8.16.ie.css (0ms) (pid 19108)</li> <li>Compiled jquery.js (5ms) (pid 19108)</li> <li>Compiled jquery_ujs.js (0ms) (pid 19108)</li> <li>Compiled custom.css (14ms) (pid 19108)</li> </ul> <p><code>custom.css</code> is <code>custom.css.scss</code></p> <p>Compile pure CSS and pure JS is fast ( cost almost 0 ms). But compile .scss and .coffee still cost some time.</p> <h2>Summarize</h2> <ol> <li>replace deploy.rb assets task.</li> <li><p>check logs/production.log</p> <ul> <li>find slow assets</li> <li>remove @import "compass"; use alternative solution.</li> <li>use require instead @import; ( use @import when it is really necessary )</li> <li>remove require_tree, mount assets individually</li> <li>remove empty .scss and .coffeescript</li> <li>use .css when assets are pure CSS.</li> </ul></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload