var script = document.createElement("script"); script.src = '/static/js/view/'+url+'.js'; var done = false; script.onload = script.onreadystatechange = function() { if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { done = true; script.onload = script.onreadystatechange = null; document.body.removeChild(script); } }; document.body.appendChild(script);