È facile dimostrarti il contrario...
Soprattutto i nuovi script NON vengono appesi al body, ma all'head, PRIMA che il caricamento sia completato. Puoi fare tutte le prove del mondo, ti dimostreranno quello che dico.codice:<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Documento HTML</title> <script type="text/javascript"> var importScript = (function (oHead) { function loadError (oError) { throw new URIError("Lo script " + oError.target.src + " non è raggiungibile."); } return function (sSrc, fOnload) { var oScript = document.createElement("script"); oScript.type = "text\/javascript"; oScript.src = sSrc; oScript.onerror = loadError; if (fOnload) { oScript.onload = fOnload; } oHead.appendChild(oScript); } })(document.getElementsByTagName("head")[0]); importScript("tuoScript1.js"); importScript("tuoScript2.js", function () { alert("Se vedi questo alert significa che lo script è stato caricato correttamente."); }); </script> <script type="text/javascript"> alert("Questo alert si trova dentro l\'head e viene lanciato DOPO l'avvio del caricamento degli script"); </script> </head> <body> </body> </html>![]()

Rispondi quotando