My research didn't prove very succsessful since I don't really know how to explain it when it is not by example.
Consider the following:
You have a webpage. One div of the webpage will by dynamic, meaning that it will load different things, like tables, paragraphs, ect ect.
Let's have set the div's id to 'main' and have this for conveneance:
var main = document.getElementById("main");
Now, this is the tricky part: When you want to change it's children you have 2 options:
1) Remove all children; create a variable in javascript for each new element; style it; set inner html; append. Example:
//Consider that the children have already be cleared
var p = document.createElement("p");
p.innerHTML = "Hello World";
p.className = "style";
main.appendChild(p);
var p2 = document.createElement("p");
p2.innerHTML = "Goodbye world!";
p2.className = "byeStyle";
main.appendChild(p);
2) Set the inner html of the variable to, basically what you want it to be. Example2:
main.innerHTML = '<p class="style">Hello world!</p>' +
'<p class="byeStyle">Goodbye world!</p>';
Both will work fine. Which is preferred and which has better performance?
document.createTextNodeto make the elements' contents.innerHTMLis usually much faster. Browsers have optimized HTML parsers, since that's what they do 99% of the time.