Is it guaranteed that this code
function runEmbeddedJSInPageEnvironment(code) {
var e = document.createElement('script');
e.type = 'text/javascript';
e.appendChild(document.createTextNode(code));
(document.head || document.documentElement).appendChild(e);
e.parentNode.removeChild(e);
}
runEmbeddedJSInPageEnvironment("$('#someform').off('submit');");
will wait for the code passed to the runEmbeddedJSInPageEnvironment
to finish first, and only then remove it from the page by calling removeChild
function?
Or can it be removed before this code finished to execute?