Initially I kept below code statically in Index.html and it works.
<script src="/le.min.js"></script>
<script>
LE.init({
token: 'token',
region: 'x'
});
</script>
due to my requirement I decided to load dynamically for that I wrote sample code.
//loads librabry
jsScript = document.createElement('script');
jsScript.src = `/le.min.js`;
document.head[0].appendChild(jsScript);
//loads initialise function in the script
script = document.createElement('script');
script.innerHtml= `LE.init({
token: '${TOKEN}',
region: 'US'
});`
document.head[0].appendChild(script);
both are appending rightly but it throwing error LE is not defined
.If I append the initialise func script as type=text
no error but no initialise would happen. How can I achieve this ?