document.write は、ドキュメントが表示可能になる前にのみ使用できます。ビルド中はインラインで使用する必要があります。ドキュメントの準備ができた後に使用すると、対面などの問題が発生します。
jQuery を使用している場合は、getScript関数を使用できます。
window.setTimeout(function() {
$.getScript('script.js',function(){
//this is your callback function to execute after the script loads
});
}
,10000
);
または、javascript のみを使用している場合は、この質問が役立つ場合があります。彼らは以下を使用します:
(function(d, t) {
var g = d.createElement(t), // create a script tag
s = d.getElementsByTagName(t)[0]; // find the first script tag in the document
g.src = 'your-script.js'; // set the source of the script to your script
s.parentNode.insertBefore(g, s); // append the script to the DOM
}(document, 'script'));