JSFiddle - React, Tailwind, and code Playground
HTML
<table id="table1"></table>
JavaScript
var responseinjson = [];
for(var i = 0; i < 1000; i++){
responseinjson.push({"param1":"value1","param2":"value2"});
}
slow();
fast();
function slow(){
var tablevar = $("#table1");
tablevar.empty();
console.time('slow');
$.each(responseinjson, function(key,value) {
var rowNew = $("<tr><td><td></td></tr>");
rowNew.children().eq(0).text(value['param1']);
rowNew.children().eq(1).text(value['param2']);
rowNew.appendTo(tablevar);
});
console.timeEnd('slow');
}
function fast(){
var table = document.getElementById('table1');
while(table.firstChild){ table.removeChild(table.firstChild); }
console.time('fast');
$.each(responseinjson, function(key, value) {
// Insert a row in the table at row index 0
var newRow = table.insertRow(0);
// Insert a cell in the row at index 0
var newCell = newRow.insertCell(0);
// Append a text node to the cell
newCell.appendChild(document.createTextNode(value['param1']));
newCell.appendChild(document.createTextNode(value['param2']));
});
console.timeEnd('fast');
}