`; Array.from(div.childNodes).forEach(function(node) { if(node.tagName === 'SCRIPT') { var s = document.createElement('script'); Array.from(node.attributes).forEach(function(attr){ s.setAttribute(attr.name, attr.value); }); s.text = node.text; document.head.appendChild(s); } else { document.head.appendChild(node); } }); });