[SOLVED]Preload components in background after app start

I am using lazy loading with ionicpage decorator for my app. Some of the pages which use lot of input elements take some time to show when i click the button for the first time. Repeat clicks show the pages quite fast as they were already loaded at least once.

The benifit of lazy loading is that the initial time to start the app is very less and this is beneficial for large apps particularly.

Is there anyway i can load the views in the background so that when i click the button, it does not take the time to show at first? The reason i ask this is that the delay is noticeable.

Interesting idea, never seen it used or talked about here. Hope someone knows more.

As described in the docs you just need to set preloadModules to true in your application config:

IonicModule.forRoot(MyApp, {
  preloadModules: true
})
3 Likes

Awesome, have not tried it yet but will this increase the first startup time of the app?

It shouldn’t as

Preloading eagerly loads all deep links after the application boots instead of on demand as needed.

I preload about 20 pages and the first few seconds the app lags a bit…

1 Like

This works great. Thanks guys.

Anything similar for the tabs ?

Oh My Precious. This literary saved my back.
THANK YOU