HTML Preparation code:
x
 
1
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
2
<style>
3
   .dom-user {
4
      color: blue;
5
   }
6
   .dom-suffix {
7
      color: red;
8
   }
9
   .dom-img {
10
      height: 16px;
11
      width: 16px;
12
   }
13
   .css-user {
14
       color: blue;
15
   }
16
   .css-user[suffix]:after {
17
       color: green;
18
       content: attr(suffix);
19
   }
20
   .css-user[img]:before {
21
       content: attr(img, url);
22
   }
23
24
25
</style>
26
<div id='list'></div>
Script Preparation code:
 
var users = [];
for (var i = 0; i < 10; ++i) {
  users.push({
    'username': 'user ' + i,
    'img': 'https://www.google.com/images/branding/product/ico/googleg_lodp.ico',
    'suffix': '(' + i + ')'
  });
}
var list = $("#list");
Tests:
  • dom text suffix

     
    list.empty();
    for (let user of users) {
      list.append($(`<span class='dom-user'>${user.username}</span><span class='dom-suffix'>${user.suffix}</span>`));
    }
  • dom text suffix two parts

     
    list.empty();
    for (let user of users) {
      list.append($(`<span class='dom-user'>${user.username}</span>`))
      list.append($(`<span class='dom-suffix'>${user.suffix}</span>`));
    }
  • css text suffix

     
    list.empty();
    for (let user of users) {
      list.append($(`<span class='css-user' suffix='${user.suffix}'>${user.username}</span>`));
    }
  • css text img suffix

     
    list.empty();
    for (let user of users) {
      list.append($(`<span class='css-user' img='${user.img}' suffix='${user.suffix}'>${user.username}</span>`));
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    dom text suffix
    dom text suffix two parts
    css text suffix
    css text img suffix

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36 OPR/41.0.2353.46
Opera 41 on Windows
View result in a separate tab
Test name Executions per second
dom text suffix 1782.0 Ops/sec
dom text suffix two parts 1028.8 Ops/sec
css text suffix 2053.6 Ops/sec
css text img suffix 1990.1 Ops/sec