JSFiddle - React, Tailwind, and code Playground
JavaScript
function createFragment(htmlStr) {
var frag = document.createDocumentFragment(),
temp = document.createElement('div');
temp.innerHTML = htmlStr;
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
return frag;
}
// You can use native DOM methods to insert the fragment:
document.body.appendChild(createFragment('<div>Hello!</div><p>...fdsfdsafdsafdsaf</p>'));