How to insert any string like <script>console.log('it works');</script> into browser DOM and see "it works" in browser console then?
jQuery's append function doing the thing:
$('html').append('<script>console.log('it works');
but I am looking for light solution, ideally plain js
context: the string can be complex like <div><h1>Title</h1></div><div><script>console.log('it works');</script></div> - it should renders correct in the DOM and do all the JS staff
<script>element explicitly. Inserting it viainnerHTMLwill intentionally not work as defined by the spec.