Вариант...
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
function createTable( fragment ) {
var table, row, data;
table = document.createElement('table');
table.border = 1;
for (var k = 0; k < 4; k++) {
row = table.insertRow(k);
for (var m = 0; m < 5; m++) {
data = row.insertCell(m);
data.textContent = "строка " +k+"; яч "+m;
if (k == m) {
data.style.backgroundColor = 'red';
//data.style.borderColor = 'red';
//data.style.color = 'red';
}
row.appendChild(data);
}
table.appendChild(row);
}
return table;
}
function run() {
var tstart = new Date();
var fragment = document.createDocumentFragment();
for (var i = 0; i < 10000; i++) {
fragment.appendChild(createTable());
}
document.body.appendChild(fragment);
alert(new Date() - tstart);
}
</script>
<button onclick="run()">Запуск</button>
</body>
</html>