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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 120
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
insertRow()
25909.0 Ops/sec
Append innerHTML
0.4 Ops/sec
insertAdjacentHTML()
18745.3 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);