Talk the guys. This is a conceptual doubt.
Recently I started developing a SPA application ( Single Page Aplication ) making use of the partial rendering concept, using ui Router
(more information about a Router here ).
It was then that as the application was growing and getting more functionality and more information I saw that for the SPA concept I had a single page - can call as you want (index.html, layout.html, base.html, etc ...) - and in it I import dozens of javascript files, as they represent my application.
And as it is a SPA and only parts of the pages are rendered according to the request I need all components, drivers, directives and etc to be available as soon as I start the application.
This causes a cascading effect, because the larger the application, the larger the number (or size) of files that my page loads as soon as the user logs in.
Example:
I have the following files
app.js
routes.js
controllers/
|--------- users/
|--------------- UserControler.js
|--------------- UserProfileController.js
|--------- appointments/
|--------------- AppointmentsControler.js
|--------- tasks/
|--------------- TasksControler.js
|--------------- TasksManagerController.js
directives/
|--------- basic/
|--------------- DropdownPattern.js
|--------- users/
|--------------- RefreshForm.js
services/
|--------- users/
|--------------- UsersServices.js
And so it goes, here was just an example (very close to my application)
Then the main page of my application stays.
<script type="text/javascript" src"libs/angularjs.js">
<script type="text/javascript" src"libs/ui-router.js">
<script type="text/javascript" src"libs/angular-resource.js">
<script type="text/javascript" src"app.js">
<script type="text/javascript" src"routes.js">
<!-- Controllers import -->
<script type="text/javascript" src"controllers/users/UserControler.js">
<script type="text/javascript" src"controllers/users/UserProfileController.js">
<script type="text/javascript" src"controllers/appointments/AppointmentsControler.js">
<script type="text/javascript" src"controllers/tasks/TasksControler.js">
<script type="text/javascript" src"controllers/tasks/TasksManagerController.js">
<!-- Directives import -->
<script type="text/javascript" src"directives/basic/DropdownPattern.js">
<script type="text/javascript" src"directives/users/RefreshForm.js">
<!-- Services import -->
<script type="text/javascript" src"services/users/UsersServices.js">
You can understand where I want to go right?
Is this the right architecture for a SPA application? Is there another way to use server routes to load files as they are being requested?
Why do I imagine that in the final application the first load of the page where ALL will be loaded to stay in the browser cache will be a very time-consuming load.