Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So I ran some tests based on @SWilk's advice. Here's how I did it :</p> <p>1) Set up a basic HTML page with an empty <code>&lt;style&gt;</code> tag in the <code>&lt;head&gt;</code> and the simple example he provided in a <code>&lt;script&gt;</code> tag at the bottom of the <code>&lt;body&gt;</code> :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;Performance test&lt;/title&gt; &lt;style&gt; /**/ &lt;/style&gt; &lt;/head&gt; &lt;body onload="onLoad()"&gt; &lt;div class="container"&gt;&lt;/div&gt; &lt;script&gt; function onLoad() { var now = new Date().getTime(); var page_load_time = now - performance.timing.navigationStart; console.log("User-perceived page loading time: " + page_load_time); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>2) Fill up the <code>div.container</code> with loaaads of HTML. In my case, I went to html-ipsum.com (no advertising intended), copied each sample, minified it all together, and duplicated it a bunch of times. My final HTML file was <strong>1.70 MB</strong>, and the <code>div.container</code> had <strong>33264</strong> descendants (direct or not ; I found out by calling <code>console.log(document.querySelectorAll('.container *').length);</code>).</p> <p>3) I ran this page 10 times in the latest Firefox and Chrome, <em>each time with an empty cache</em>.</p> <p><strong>Here are the results without the dreaded CSS ruleset (in ms) :</strong></p> <pre><code>Firefox : 1785 1503 1435 1551 1526 1429 1754 1526 2009 1486 Average : 1600 Chrome : 1102 1046 1073 1028 1038 1026 1011 1016 1035 985 Average : 1036 </code></pre> <p>(If you're wondering why there's such a difference between those two, I have much more extensions on Firefox. I let them on because I thought it would be interesting to diversify the testing environments even more.)</p> <p>4) Add the CSS we want to test in the empty <code>&lt;style&gt;</code> tag :</p> <pre><code>html:before, html:after, body:before, body:after, div:before, div:after, p:before, p:after, ul:before, ul:after, li:before, li:after, h1:before, div:after, strong:before, strong:after, em:before, em:after, code:before, code:after, h2:before, div:after, ol:before, ol:after, blockquote:before, blockquote:after, h3:before, div:after, pre:before, pre:after, form:before, form:after, label:before, label:after, input:before, input:after, table:before, table:after, thead:before, thead:after, tbody:before, tbody:after, tr:before, tr:after, th:before, th:after, td:before, td:after, dl:before, dl:after, dt:before, dt:after, dd:before, dd:after, nav:before, nav:after { content: ''; } </code></pre> <p>...and start again. Here I'm specifying every tag used in the page, instead of <code>*</code> (since it is counter-performant in itself, and we want to monitor the pseudo-element triggering only).</p> <p><strong>So, here are the results with all pseudo-elements triggered (still in ms) :</strong></p> <pre><code>Firefox : 1608 1885 1882 2035 2046 1987 2049 2376 1959 2160 Average : 1999 Chrome : 1517 1594 1582 1556 1548 1545 1553 1525 1542 1537 Average : 1550 </code></pre> <p>According to these numbers, <strong>we can conclude the page load is indeed slower (of about 400-500 ms) when declaring <code>content: ''</code> on every pseudo-element</strong>.</p> <p>Now, the remaining question now is : <strong>is the extra load time we can see here significative, given the relatively big test page that was used</strong> ? I guess it depends on the size of the website/project, but I'll let more web-performance-knowledgeable people give their opinion here, if they want to.</p> <p>If you run your own tests, feel free to post your conclusions here as well, as I'm very interested in reading them - and I think I won't be the only one.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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