Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
Chrome 87
Linux
Desktop
3 years ago
Test name Executions per second
jQuery: get html 0.0 Ops/sec
get innerHTML 68010.4 Ops/sec
jQuery: set html 0.0 Ops/sec
set innerHTML 59567.6 Ops/sec
HTML Preparation code:
AخA
 
1
<ul id="theList">
2
  <li class="odd">Item 1</li>    
3
  <li class="even">Item 2</li>    
4
  <li class="odd">Item 3</li>    
5
  <li class="even">Item 4</li>    
6
  <li class="odd">Item 5</li>    
7
  <li class="even">Item 6</li>    
8
  <li class="odd">Item 7</li>    
9
  <li class="even">Item 8</li>    
10
  <li class="odd">Item 9</li>    
11
  <li class="even">Item 10</li>    
12
  <li class="odd">Item 11</li>    
13
  <li class="even">Item 12</li>    
14
  <li class="odd">Item 13</li>    
15
  <li class="even">Item 14</li>    
16
  <li class="odd">Item 15</li>    
17
  <li class="even">Item 16</li>    
18
  <li class="odd">Item 17</li>    
19
  <li class="even">Item 18</li>    
20
  <li class="odd">Item 19</li>    
21
  <li class="even">Item 20</li>    
22
  <li class="odd">Item 21</li>    
23
  <li class="even">Item 22</li>    
24
  <li class="odd">Item 23</li>    
25
  <li class="even">Item 24</li>    
26
  <li class="odd">Item 25</li>    
27
  <li class="even">Item 26</li>    
28
  <li class="odd">Item 27</li>    
29
  <li class="even">Item 28</li>    
30
  <li class="odd">Item 29</li>    
31
  <li class="even">Item 30</li>    
32
</ul>
Script Preparation code:
 
var el = document.getElementById('theList');
Tests:
  • jQuery: get html

     
    var html = $(el).html();
  • get innerHTML

     
    var html = el.innerHTML;
  • jQuery: set html

     
    $(el).html('<li>Item A</li><li>Item B</li>');
  • set innerHTML

     
    el.innerHTML = '<li>Item A</li><li>Item B</li>';