JSFiddle - React, Tailwind, and code Playground
CSS
div{
border: 1px solid #eee;
display: inline-block;
width: 2px;
height: 2px;
}
JavaScript
var bench = function(fn, iterations){
var time = 0, i = 0, total = 0;
// start
time = +(new Date);
while(i < iterations){
fn.apply();
i++;
}
total = +(new Date) - time;
console.log("Mean exec time: ", total / iterations, 'ms');
console.log("Sum exec time: ", total, 'ms');
}
var test1 = function(){
$('body').append('<div />');
},
test2 = function(){
div = document.createElement('div');
document.body.appendChild(div);
};
bench(test1, 1000);
bench(test2, 1000);