1 minute app load time

I see this other thread about load time, but it does not seem to address my problem. My app is taking a full minute to load on Android, 25 seconds on iOS. I wonder if anyone has any ideas for me that weren’t covered in the other thread.

It seems like my load time is coming from the number of pages in my app. It has 63 pages (plus 19 pipes and services files). The app size is reasonable, 4.5MB for the .ipa, 4.3MB for the .apk. My iPhone says it is using 23MB when it is loaded, which seems good compared to other apps in the phone. If I strip the app down to 1 page (leaving in the 19 pipes and services files), I see a reasonable 5 second iOS load time, with a 3.9MB .ipa and seeing 19.3MB in the iPhone.

So I guess the app is loading or doing something with all of my pages before it starts up. If so, is there a way to lazy-load the pages or …?

I’m running 2.0.0 and I was seeing the same thing with RC4. I am using the --prod flag (though android seems to also need the --release flag). I do not have crosswalk, and there are very few image assets.

I don’t have any solution for you, but I’m wondering the same thing. Mine is quite a bit smaller at 19 pages, 4 pipes, 14 providers, 3 custom components, but it’s also pretty slow on android. Not 1 minute slow, but sluggish enough that it’s noticeable that you’re sitting there staring at a splash screen for longer than you should.
I am using crosswalk, I haven’t done any with/without comparisons, I started with it - but I think it’s supposed to help.

The --prod flag is working well with some and is not with others, which is really strange.
Mine got reduced from almost 40 sec to 2 sec using --prod flag.

Yeah, I’m using the prod flag. It helps, actually without the prod flag my app seems to timeout on boot or something

I’ve the same problem since I upgrade from rc2 to 2.0.0 final, the load time has increased at least in Android, even using the --prod flag. When splash screen disappear, no even the headbar is loaded…

I don’t know if is an ionic issue or something that it’s making my app slower. I’m using the last ionic version:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: OS X El Capitan
Node Version: v6.9.4

Ok, finally I have achieved better loading times, 3 seconds on a Samsung S7 and 5-6 seconds on Samsung S5 (from tap to load home).

At least, in my case, was my fault. I had a provider with a platform.ready in constructor, linked on my app.component.

Interesting, I didn’t realize that was a no-no. I’ll have to check mine for such occurrences, is there a best practice for something like that? How did you get around it?

use ngOnInit() most of the times where you think u need constructor(). keep constructor only to construct models etc. all api/service related should go ngOnInit()

I can confirm that moving a lot of stuff from the constructor to lifecycle events (particularly ngOnInit on the app.component, ionViewDidEnter for pages) made a huge difference in startup time.

1 Like

Is good to check all providers that you linked in app.component constructor, because all the code inside every provider constructor loads before that your app.component code. As nylex said, is a good idea use ngOnInit() or as you say ionViewDidEnter.

I tried ngOnInit in my providers as well but it never fired - is there something else for providers?

Interesting discussion but none of that appears to be my problem.

Check that you have an updated ionic app-scripts version. Should be 1.0.0

hi , I am also having the same problem with loading time… i managed to make it 3.5 seconds…but the first you install the app it takes 6 seconds… 3.5 seconds is still a lot of time… does having some plugins inside platform.ready in the app.component affect loading time? for example, I have an operation (contact plugins) inside platform.ready in app.component where it gets contacts info and puts it in storage.

my point is, should I reduce such things in app.component for better loading time, or it does not really affect the loading time… Also, I didnt really get what you said about provider with a platform ready in constructor… do all code in the constructor of the pages load at once when you start the app, and if so then that is the problem i think !! I would be so grateful if you can explain more… I dont have much things in the app yet and it take 3.5 seconds after the splashscreen to load… its a disaster