在我的项目中使用require Js。一切似乎都很好。没有JS冲突。
但是,当我按下CTRL + F5以清除在Firefox中重新加载页面时,我观察到55个Javascript文件正在加载,参考Firebug中的NET选项卡。
这是正常的吗?我做错了吗?
这是我的BOOT.js
require
.config({
baseUrl : 'resources/js',
paths : {
domReady : 'lib/domReady',
jquery : 'lib/jquery.min',
jqueryUI : 'lib/jquery-ui-1.9.2.custom.min',
date : 'lib/date',
tmpl : 'lib/jquery.tmpl.min',
underscore : 'lib/underscore-min',
backbone : 'lib/backbone',
handlebars : 'lib/handlebars-v1.1.2',
socket : 'lib/knotifyjs',
eve : 'lib/eve',
raphael : 'lib/raphael-min',
chronoline : 'lib/chronoline',
fullcalendar : 'lib/fullcalendar',
timeago : 'lib/jquery.timeago',
openStreet : 'lib/openstreet/OpenLayers',
timeago : 'lib/jquery.timeago',
foundation : 'lib/foundation.min',
fDropdown : 'lib/foundation.dropdown',
fTopBar : 'lib/foundation.topbar',
jgrowl : 'lib/jquery.jgrowl.min',
jQgrid : 'lib/jqgrid',
jQgridLocale : 'lib/jgrid-locale',
jqueryForm : 'lib/jquery.form',
validateForm : 'lib/validate',
jsPlumb : 'lib/jquery.jsPlumb-1.3.16-all',
carousel : 'lib/carousel.min',
spin : 'lib/spin',
datePicker : 'lib/jquery-ui-timepicker-addon',
timeSlider : 'lib/jquery-ui-slider-access',
maps : 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false',
autoCompleteMap : "https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places",
weather : 'lib/jquery.zweatherfeed.min',
picker : 'lib/picker',
jsonQLang : 'lib/JSLINQ',
pickerTime : 'lib/picker.time',
jqueryFlot : 'lib/jquery.flot',
jFlotCategory : 'lib/jquery.flot.categories',
jFlotTime : 'lib/jquery.flot.time',
jFlotAxisLabel : 'lib/jqflot-axislabels',
"moment" : "lib/moment.min",
"moment-timezone" : "lib/moment-timezone.min",
"moment-timezone-data" : "lib/timezone-data",
jScrollPane : 'lib/jquery.jscrollpane.min',
app : 'app'
},
waitSeconds : 300,
shim : {
"jqueryUI" : {
deps : [ 'jquery' ],
exports : "jqueryUI"
},
"datePicker" : {
deps : [ 'jquery', 'jqueryUI' ],
exports : 'datePicker'
},
"timeSlider" : {
deps : [ 'jquery' ],
exports : 'timeSlider'
},
"jqueryForm" : {
deps : [ 'jquery' ],
exports : "jqueryForm"
},
"jsonQLang" : {
deps : [ 'jquery' ],
exports : "jsonQLang"
},
"picker" : {
deps : [ 'jquery' ],
exports : 'picker'
},
"pickerTime" : {
deps : [ 'jquery' ],
exports : 'pickerTime'
},
"backbone" : {
deps : [ 'jquery', 'underscore' ],
exports : 'Backbone'
},
"handlebars" : {
deps : [ 'jquery', 'underscore', 'backbone' ],
exports : 'Handlebars'
},
"tmpl" : {
deps : [ 'jquery' ],
exports : 'tmpl'
},
'eve' : {
exports : "eve"
},
'raphael' : {
deps : [ "eve" ],
exports : "Raphael"
},
"fullcalendar" : {
deps : [ "jquery" ],
exports : "fullcalendar"
},
"map" : {
deps : [ 'jquery' ],
exports : "maps"
},
"autoCompleteMap" : {
deps : [ 'jquery' ],
exports : "autoCompleteMap"
},
"jqueryFlot" : {
deps : [ 'jquery' ],
exports : "jqueryFlot"
},
"jFlotCategory" : {
deps : [ 'jqueryFlot' ],
exports : "jFlotCategory"
},
"jFlotAxisLabel" : {
deps : [ 'jqueryFlot' ],
exports : "jFlotAxisLabel"
},
"jFlotTime" : {
deps : [ 'jquery' ],
exports : "jFlotTime"
},
"foundation" : {
deps : [ 'jquery' ],
exports : 'foundation'
},
"timePicker" : {
deps : [ 'jquery' ],
exports : 'timePicker'
},
"fTopBar" : {
deps : [ 'jquery', 'foundation' ],
exports : 'fDropdown'
},
"fDropdown" : {
deps : [ 'jquery', 'foundation' ],
exports : 'fTopBar'
},
"validateForm" : {
deps : [ 'jquery' ],
exports : "validateForm"
},
"jQgridLocale" : {
deps : [ 'jquery' ],
exports : 'jQgridLocale'
},
"jQgrid" : {
deps : [ 'jquery', 'jQgridLocale' ],
exports : 'jQgrid'
},
"jsPlumb" : {
deps : [ 'jquery' ],
exports : 'jsPlumb'
},
"openStreet" : {
deps : [ 'jquery' ],
exports : 'openStreet'
},
"jgrowl" : {
deps : [ 'jquery' ],
exports : 'jgrowl'
},
"weather" : {
deps : [ 'jquery' ],
exports : 'weather'
},
"carousel" : {
deps : [ 'jquery' ],
exports : 'carousel'
},
"spin" : {
exports : 'spin'
},
"jScrollPane" : {
deps : [ 'jquery' ],
exports : "jScrollPane"
}
}
});
答案 0 :(得分:1)
为什么它不对?当您处于开发模式时,RequireJS将异步加载您的代码所需的所有文件。一旦准备好进入生产模式,就应该使用r.js来优化构建并生成一个JS文件,以便提供给浏览器。