Can modular programming contribute to lower loading time and how?
I read about ways to Modularize AngularJS applications. In general the reason for doing so is to have a good structure when creating large apps, such that one does not have to scroll to much between files and a separation is made between re-usable and standalone modules.
While this definitely makes sense from a practical point of view, I can't barely find arguments that support loading time?
Will referencing the .js files in the seperate .html files instead of all in index.html reduce loading time?
I was thinking the following; if you have a directory structure as below (Directory Structure Example). The loading time then will decrease if you the inlcude the .js
references in the individual .html
files instead of all in index.html
. For instance, in sidebarView.htm
l you would add:
<script src='sidebarDirective.js'></script>
Directory Structure Example
app/
----- shared/ // acts as reusable components or partials of our site
---------- sidebar/
--------------- sidebarDirective.js
--------------- sidebarView.html
---------- article/
--------------- articleDirective.js
--------------- articleView.html
----- components/ // each component is treated as a mini Angular app
---------- home/
--------------- homeController.js
--------------- homeService.js
--------------- homeView.html
---------- blog/
--------------- blogController.js
--------------- blogService.js
--------------- blogView.html
----- app.module.js
----- app.routes.js
assets/
----- img/ // Images and icons for your app
----- css/ // All styles and style related files (SCSS or LESS files)
----- js/ // JavaScript files written for your app that are not for angular
----- libs/ // Third-party libraries such as jQuery, Moment, Underscore, etc.
index.html