Hello, I have the following code
<html>
//=======Teste1========
<script
type="text/javascript"
src="http://modulo.que.sera.carregado.js"data-token="">
</script>
//=======Teste2========
<script>
scriptTeste = function() {
var dados = JSON.parse(localStorage.dados);
var node = document.createElement("script");
var att = document.createAttribute("data-token");
att.value = dados.token;
node.setAttributeNode(att);
document.getElementById("idBody").prepend(node);
}
scriptTeste();
</script>
</html>
The value of the data-token will come through the user session, and I need to add it to the script. After loading this initial script another script must be loaded, depending on which modules are loaded first.
I added in the above example the two codes I tested.
Test1 worked only when I left the value of the fixed data-token. Test2 did not work because the second script that will be loaded does not expect this first script to finish loading the modules.