당신은 아마 스크립트의 지연로드해야합니다. 이 Lazy Loading의 마지막 예제는 YUI를 통해 .js를로드하는 것을 보여줍니다. 이 예제 코드는 참조 용으로 아래에 포함되어 있습니다 : 당신이 가능하게 초기 로딩 이미지를로드하고 콜백 함수를 제거 할 수
var HelloWorld = {
is_loaded: false,
lazyLoad: function(callback) {
var loader = new YAHOO.util.YUILoader();
loader.addModule({
name: "helloworld",
type: "js",
fullpath: "yui_ex/helloworld.js"
});
loader.require("helloworld");
if (callback) {
loader.onSuccess = callback;
}
loader.insert();
},
sayIt: function() {
var args = arguments;
HelloWorld.lazyLoad(function() { HelloWorld.sayIt.apply(HelloWorld, args); });
}
};
참고. 그래서 질문을 JQuery to load Javascript file dynamically 읽기, 당신은 또한 $.getScript() 같은 일을 할 수 있습니다.
this link
에서 다른 예를 찾을 수도 있습니다.