I'm looking for a way in the purpose to speed up site loading and postpone non-urgent scripts. I need to load a script on button click as it placed in Head tag <script ...>.
async function do_script_load() {
var script = document.createElement("script");
script.src = "https://web.webformscr.com/apps/fc3/build/loader.js";
script.type = "text/javascript";
script.setAttribute("async", "");
await item.parentElement.querySelector(".n-bell-bubble").appendChild(script);
do_other_stuff();
}
addEventListener( "click" , () => {
do_script_load()
})
The problem is that the script get loaded but it is not being started. I'm looking for a way to run the script as a script added as used to.
<head>
<script src="..." async></script>