Speed up initial loading
We're developing an app which is partially native and partially hybrid. We will open cordova activity when user clicks on an menu item and finish the activity when user clicks back. Problem with this approach is, it takes a while to render on the screen for first time. We are hosting all the resource files in the assets folder so caching doesn't make much sense. Is there any progressive way to load the application?
i created a new ionic2 rc-0 project with side menu. I used ionic serve --lab, and when i click the icon at the left side of header bar, the menu doesn't not come out. only when i slide or click the menu toogle button that it slides
@danbucholtz I wanted to thank the Ionic team for releasing RC0! Even though I had to invest some time to migrate my app due to all the changes, the startup time of my app improved significantly! For example, on a 3 year old Samsung Galaxy 4 the startup time with beta 11 was ~6 seconds which RC0 reduced to ~3 seconds! It's a great improvement so well done :)
@abhayastudios, w00t! Thanks!
We have more improvements and optimizations in store, too!
Thanks, Dan
We too have had our load time slash by about 50%. Great work guys. Really loving working with this framework.
I know this doesn't help but I just recently dived into ionic and I am using 2.0.0-rc.2 , I noticed how slow the initial load was compared to an app that was built on 1.1.1
@geocine I noticed the same thing, in an older v1 app, the startup time is very good but while Ionic v2 provides a much nicer programming environment, the startup times are very slow in my app (>5 seconds in release build on a relatively fast device with Android 6.0). Is the Webpack build doing tree shaking?
If it really takes time to load , perhaps is there a way to atleast show a splashscreen that I can show in under a second during loading?
@geocine That's why you usually use the cordova splash screen plugin (https://github.com/apache/cordova-plugin-splashscreen) and hide it onDeviceReady.
Is there any easy way to profile the app startup time? I'm using Chrome remote debugger to profile the app, however that lets me connect to the app only after it's already initialized (so I cannot profile the startup) and it closes when I exit the app, so I cannot relaunch it and profile the startup this way.
I'm asking this because I'm having problems with my app startup time on Android, which is above 5 seconds. Even when I use the plain Ionic 2 tutorial app, it starts only after 4-5 seconds on a relatively performant device (Sony Z3 compact, 6.0.1). That's really slow (my old Ionic 1 app with a few plugins takes < 3 seconds to start).
Are there any plans to (significantly) reduce Ionic 2 app startup times? Developing with Ionic 2 is great, but I'm afraid that otherwise I'll have to switch to another framework :-(
Are there any plans to add support for Lazy loading, this could also be helpful in reducing initial load time. Angular cli which uses webpack now supports Lazy loading and with AoT a well designed angular app can significantly reduced load time. Since Ionic also uses webpack, I think this can be done for Ionic as well.
urgent needs for Lazy loading.
The ionic team meeting doc said that they are working in treeshaking, so probably this will reduce the bundle size and will speed up a little the boot up time.
Tree shaking is great, but it can only do so much. Lazy loading is an important separate concern, and so far, the ionic team hasn't expressed much interest in it according to comments I've seen in other issues (e.g. https://github.com/driftyco/ionic/issues/8102). Unfortunately, many people seem to think it's only useful in web apps, even though it can also be incredibly useful in mobile apps too.
@rob3c and others,
Lazy loading is something we're looking at and would like to explore more. Expect to hear more on this topic in the coming months.
Thanks, Dan
@danbucholtz, Beyond lazy loading, are you exploring any other solutions that could significantly reduce the start up time?
Right now, this is the number 1 reason we are not adopting Ionic 2 in new projects. I don't know if you could share with us some information about what is in process. Thanks!
Well this is a problem with javascript in general and not specific to ionic. It is interesting to see what other frameworks are doing about it. For example I stumbled upon a related article on a "competive" framework's website using what is called "code caching" in the v8 engine to vastly improve startup performance.
The startup time has gotten a lot worse after Angular 2 switched to modules due to AoT. In NativeScript, which also has problems with long startup time, it seems that it's fine without Angular 2 (https://github.com/NativeScript/nativescript-cli/issues/371). In june my app was starting relatively fast, but after Ionic 2 switched to newer version of Angular 2, it now takes >= 5 seconds and that is unusable for production. Are you aware of any Angular 2 improvements that are in the making to improve this or is treeshaking and lazy loading the only way?
@Kobzol,
That is strange, AoT definitely results in a significantly faster start-up time (typically, anyway, I am sure there are edge cases).
@SynerG,
Start-up time is pretty fast with AoT. You sure you were testing with AoT? Our bundle size is still relatively large and we are working on bringing that down. It isn't completely huge though unless you import a bunch of large libraries. Often times small libs become huge due to a bunch of nested dependencies.
Thanks, Dan
I don't know if I'm doing anything wrong, but I tried to run AOT prod builds of the Ionic 2 tutorial starter template with both webpack and rollup and it takes > 5 seconds to start on my device (Sony Z3 Compact with Android 6.0.1), whereas an older Ionic 1 app starts in 3 seconds. The startup got worse over the last couple of months, when Angular 2 switched to the module system (the same happened with my nativescript app, which slowed after the Angular switch). Maybe lazy loading could help with that.
Do you have any benchmark numbers that I could use for comparison?
5 seconds is not that bad compared to what I've been seeing. I've had to up the timeout limit in config.xml to make sure it does not timeout (default is 20 seconds!).
That was for a slower 4.4 device though. On a Sony Xperia E5 with 6.0 it is still 10-15 seconds.
iPhone 7 plus is less than 2 seconds.