In my web application I would like to complately avoid html and use only javascript to create web-page\'s dom tree.
What is faster writing web content in the traditi
(Probably the correct answer is correct for 2010). Here's an answer for 2019 with benchmark.
Generating table with nested div
, total of 500 rows, 250k table cells, 10 nested divs per table cell.
';
for($j = 0; $j < 500; ++$j) {
echo '' . $i . '/' . $j . ' ';
}
echo '';
}
?>
And the below HTML generated by JS:
| Download Size | Time 'til browser stops loading
--------------------------------------------------------------------------
Pure HTML by server | 680,000 bytes | 00:01:48
HTML generated by JS | 570 bytes | 00:00:28
Tested it on Chrome v70 on Ubuntu 18.
Always stick to normal HTML for many reasons (usually for readable/maintainable code), except if you're dealing with huge HTML then you may consider generating it by JS.