Note that there are some explanatory texts on larger screens.

plurals
  1. POWhich CSS selectors or rules can significantly affect front-end layout / rendering performance in the real world?
    primarykey
    data
    text
    <p><strong>Is it worth worrying about CSS rendering performance?</strong> Or should we just not worry about efficiency at all with CSS and just focus on writing elegant or maintainable CSS instead?</p> <p>This question is intended to be a useful resource for front-end developers on which parts of CSS can actually have a significant impact on device performance, and which devices / browsers or engines may be affected. This is <em>not</em> a question about how to write elegant or maintainable CSS, it's purely about performance (although hopefully what's written here can inform more general articles on best-practice).</p> <h1>Existing evidence</h1> <p><a href="https://developers.google.com/speed/docs/best-practices/rendering" rel="noreferrer">Google</a> and <a href="https://developer.mozilla.org/en-US/docs/CSS/Writing_Efficient_CSS?redirectlocale=en-US&amp;redirectslug=Writing_Efficient_CSS" rel="noreferrer">Mozilla</a> have written guidelines on writing efficient CSS and <a href="http://csslint.net/about.html" rel="noreferrer">CSSLint's set of rules</a> includes:</p> <blockquote> <p>Avoid selectors that look like regular expressions .. don't use the complex equality operators to avoid performance penalties</p> </blockquote> <p>but none of them provide any evidence (that I could find) of the impact these have.</p> <p>A <a href="http://css-tricks.com/efficiently-rendering-css/" rel="noreferrer">css-tricks.com article on efficient CSS</a> argues (after outlining a load of efficiency best practices) that we should <code>not .. sacrifice semantics or maintainability for efficient CSS</code> these days.</p> <p>A <a href="http://perfectionkills.com/profiling-css-for-fun-and-profit-optimization-notes/#summary" rel="noreferrer">perfection kills blog post</a> suggested that <code>border-radius</code> and <code>box-shadow</code> rendered orders of magnitude slower than simpler CSS rules. This was hugely significant in Opera's engine, but insignificant in Webkit. Further, a <a href="http://coding.smashingmagazine.com/2011/04/21/css3-vs-css-a-speed-benchmark/" rel="noreferrer">smashing magazine CSS benchmark</a> found that rendering time for CSS3 display rules was insignificant and significantly faster than rendering the equivalent effect using images.</p> <p>Know your mobile <a href="http://www.knowyourmobile.com/features/1464976/google_chrome_for_ios_vs_safari_an_indepth_speed_and_feature_test.html" rel="noreferrer">tested various mobile browsers</a> and found that they all rendered CSS3 equally insignificantly fast (in 12ms) but it looks like they did the tests on a PC, so we can't infer anything about how hand-held devices perform with CSS3 in general.</p> <p>There <a href="https://developers.google.com/speed/docs/best-practices/rendering" rel="noreferrer">are</a> <a href="https://developers.google.com/speed/docs/best-practices/rendering" rel="noreferrer">many</a> <a href="https://developer.mozilla.org/en-US/docs/CSS/Writing_Efficient_CSS?redirectlocale=en-US&amp;redirectslug=Writing_Efficient_CSS" rel="noreferrer">articles</a> on the internet on how to write efficient CSS. However, I have yet to find any comprehensive evidence that badly considered CSS actually has a <em>significant</em> impact on the rendering time or snappiness of a site.</p> <h1>Background</h1> <p><a href="http://brightgreenscotland.org/wp-content/uploads/2010/09/stand-back-Im-going-to-try-science.png" rel="noreferrer">stand back, I&#39;m going to try science http://brightgreenscotland.org/wp-content/uploads/2010/09/stand-back-Im-going-to-try-science.png</a></p> <p>I offered bounty for this question to try to use the community power of SO to create a useful well-researched resource.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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