I am developing a single-line core application using requirejs, and today, when I deployed to our beta server, I found that the initial load of the page was about 20 seconds while it was extracting all the scripts.
I assumed that this was because I used an array of dependencies when defining such modules:
define([ 'ui', 'models/user', 'collections/campaigns', 'collections/groups', 'collections/keywords', 'collections/inboxes', 'collections/templates', 'collections/contacts', 'router' ], function (Ui, UserDetails, Campaigns, Groups, Keywords, Inboxes, Templates, Contacts, Router) { return { start: function () {
I figured that when loading the main application module, all other scripts would be loaded due to the fact that each module used this method.
Then I changed the method for selecting modules to get them as needed, calling require('...') directly when I need it:
define(function (require) { return Backbone.Router(function () {
However, to my surprise, by launching the application again and checking the Network tab of the Chrome Developer Console, I saw that, as before, the application retrieves all my modules and I get the same page load time.
Have I completely missed this point? Since I had the impression that the scripts would be received on every request. This is not true?