Is there a difference between …
this
<html>
...
<div id="myDiv"> </div>';
...
</html>
var manyHtmlCode = ' ... many Html Code ... ';
// onclick -> write it in to the DIV -> $('myDiv').append(manyHtmlCode);
and this
<html>
...
<div id="myDiv" style="display:none;"> ... many Html Code ... </div>';
...
</html>
// onclick -> show content $('myDiv').show();
It is obvious to me that the second solution is faster in javascript, but what about with the browser speed?
Is the browser faster (for example, draging a div) with a smaller HTML code in the body Tag?
If so, it would be better to store not needed HTML code in a JS var. My Problem is that i have a page with many many draggable divs. Imho is the dragspeed better when the html code is smaller.
The second solution is faster for two reasons:
display: noneand not bother rendering that element nor anything inside it. This speeds up the initial render of the page, because it doesn’t actually render a lot of your HTML.