var e = scripts[i].parentElement scripts[i].remove() var script= document.createElement('script'); script.type= "text/javascript"; script.text= `скрипт`; e.append(script);