2014-03-07 4 views
1

require.js를 통해 스크립트를로드하는 시간에 대한 질문이 있습니다. 비동기 로딩은 모든 스크립트가 독립적으로로드되고 동기가 각 스크립트가 하나씩로드 될 때입니다. 하지만 난 반대의 그림을 참조하십시오 같은 require.js없이 :js 및로드 스크립트 시간이 필요합니다

<script type="text/javascript" src="templates/js/new/jquery-ui-1.10.3.custom.min.js"></script> 
<script type="text/javascript" src="templates/js/new/eventTrackerManager.v.1.0.js"></script> 
<script type="text/javascript" src="templates/js/new/constants.js"></script> 
<script type="text/javascript" src="templates/js/new/utils.js"></script> 
... 

enter image description here

과 같은 require.js로 : u는 볼 수 있듯이

require.config({ 
    baseUrl: "templates/js/new/", 
    paths: { 
     "jQuery": "lib/jquery-2.0.3.min", 
     "jQueryUI" : "lib/jquery-ui-1.10.3.custom.min", 
     "Utils" : "modules/utils", 
     "contactform" : "modules/contactform" 
       ... 
    }, 
    shim: { 
     "jQueryUI": { 
      exports: "$", 
      deps: ['jQuery'] 
     } 
    } 
}); 
require(["contactform"], function(CF) { 
    CF.init(); 
}); 

enter image description here

AMD가없는 버전은 훨씬 빠릅니다. 내가 뭘 잘못 했니?

+0

'r.js'에 대해 언급 할 때 RequireJS 최적화 도구 [r.js] (http://requirejs.org/docs/optimization.html#download)를 의미합니까, 아니라는 것을 의미합니까? – rhgb

+2

네 개의 연속적인 '

관련 문제