Does Durandal load the ViewModels/View during initial load/upfront or load them on demand.
Say i have a very huge website with 100 or more pages/View and each view has a pretty big viewModel. will Durandal Load all of them upfront ?
How about the Data Calls in each view, will all those be triggered if it is loading them upfront ?
Trying to understand the Behavior of Durandal
Durandal loads views and viewmodels as needed (on demand). So in your example, with 100 views and viewmodels, you would only be loadin gthe ones you use. Watch the Network tab of your browser tools and you can see them come across as required.
Also, once they are local, they are cached in the browser, which is a good thing.
If your viewmodel's make data calls on "activate" then yes, they will be called each time you activate them. See the Durandal docs for more about the lifecycle events.
However, if you run the optimizer.exe, it will package up all of them and bring them to the client in a single shot (minified) up front. This is not something I do during development. But, if you want to load everything up front after you go live, this is a way to get the whole app local.
For your app with 100+ views, I'd probably load as I go since it is unlikely that anyone will hit all 100 views in a single usage (I am guessing). It depends on how you intend the app to be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With