I read a piece of Javascript code, where the programmer added something similar to this:
html = "
<div class='hidden-context-menu'>
<ul><li><a class='select-all'>All</a></li>
<li><a class='select-none'>None</a></li>
...
...
...
</ul>
</div>
"
and then, in some other parts of the webapp, this piece of code is used and rendered in the page.
output_html(html);
I assume, considering this specific example of a hidden context menu, that maybe the developer did't want to repeat himself..
Is this kind of practice encouraged or it has to be considered a wrong approach?
document.createElementa bunch of times. Something to keep in mind if you're creating thousands of nodes perhaps.