Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Add rows to Table: insertRow() vs appending innerHTML vs insertAdjacentHTML
Vannilla JS version, no jquery
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0
Browser:
Firefox 111
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
insertRow()
40833.5 Ops/sec
Append innerHTML
0.5 Ops/sec
insertAdjacentHTML()
124981.1 Ops/sec
HTML Preparation code:
<table id="tbl"> <tbody></tbody> </table>
Script Preparation code:
var tbody = tbl.tBodies[0]; var data = { one: 'one', two: 'two', three: 'three', four: 'four', five: 'five' };
Tests:
insertRow()
var row = tbl.insertRow(); var cell = row.insertCell(); var textnode = document.createTextNode(data.one); cell.appendChild(textnode); cell = row.insertCell(); textnode = document.createTextNode(data.two); cell.appendChild(textnode); cell = row.insertCell(); textnode = document.createTextNode(data.three); cell.appendChild(textnode); cell = row.insertCell(); textnode = document.createTextNode(data.four); cell.appendChild(textnode); cell = row.insertCell(); textnode = document.createTextNode(data.five); cell.appendChild(textnode);
Append innerHTML
var html = '<tr>'; html += '<td>'+data.one+'</td>'; html += '<td>'+data.two+'</td>'; html += '<td>'+data.three+'</td>'; html += '<td>'+data.four+'</td>'; html += '<td>'+data.five+'</td>'; html += '</tr>'; tbody.innerHTML += html;
insertAdjacentHTML()
var html = '<tr>'; html += '<td>'+data.one+'</td>'; html += '<td>'+data.two+'</td>'; html += '<td>'+data.three+'</td>'; html += '<td>'+data.four+'</td>'; html += '<td>'+data.five+'</td>'; html += '</tr>'; tbody.insertAdjacentHTML('beforeend', html);