Ionic 2 speed up boot time?

@reedrichards Beta.11 is great news, also the plans for Webpack 2.0 is great, however waiting for Beta.12 is going to be hard.

Do you know if the AoT compilation mentioned in that announcement is inside Beta.11?

If I understand correctly I think AoT will also be in Beta.12

At least I upgrade to Beta.11 but my app still need the same amount of time to boot.

Youā€™re right, Iā€™m looking forward that next version

Is there any way to reduce the time ā€¦ we are working on production application

Simple answer: NO
Complex answer: YES by writing 100% native app.

I suppose once migration to AoT is done it will gain some startup time but Iā€™m not that much optimistic.

Check this excellent post from angular2-seed project creator:
http://blog.mgechev.com/2016/08/14/ahead-of-time-compilation-angular-offline-precompilation/

Ahh, good joke. I chuckled for a moment or 2 :grin:

The AoT Compiler will very much improve speed time. Itā€™s actually what weā€™re focusing on right now. We have it ā€œworkingā€, but are still cleaning it up to make it usable for everyone. Itā€™s quite a complicated setup, so a blog post will follow the release diving into the details.

5 Likes

and how soon we can expect the AoT version? also any eta on Deep linking?

Yep it was joke :wink:

Any benchmark numbers just to imagine how faster it will be?

No benchmarks yet, again we still need to clean it up so that way we can easily use it

@mhartington What about lazy loading components? i have another project where i take advantage of webpackā€™s code splitting to split each page into chunks and using the new Angular 2 router to achieve app load under 1 sec (~985 s and still lacks AoT to reduce even more the size and boot time).

Is still the Angular 2 router disabled? is ionic-nav going to support lazy loading?

Yes, angular router is still disabled.

We will be able to talk more about it in the next few releases.

Is there any other alternate way to decrease boot time ā€¦ ? Because we are working on Production Application ā€¦

Hi, this isnā€™t a magic bullet but a couple of articles that Iā€™ve found useful are -

https://taco.visualstudio.com/en-us/docs/cost-cordova/ (3 articles on this site regarding Cordova app performance)

Though not specifically Ionic 2 Iā€™ve used some of the techniques here to make nice performance gains in an Ionic 2 app Iā€™m currently developing.

Boot time is still not great but comparable to other Ionic 1 & 2 apps. I havenā€™t looked at that part of the app yet though.

1 Like

Sorry but, when dealing with a beta version one canā€™t expect the framework to be fast. Of course, depending on the device, the application written using ionic2 is fast / slow / very slow / very very slow.
For eg., here is my Stack Exchange app for android . Itā€™s very snappy on Samsung Galaxy Tab S2. But, is slow on CoolPad Note 3 running Android V5.1 .

2 Likes

Hi, let me say this, i have a Galaxy Tab A, which is a very good device, and the boot time doesnā€™t go under 10 sec, i guess i have to optimize a lot of things about the bundle size (maybe cut all the directives of Angular that it includes by default but i donā€™t use), and maybe using the XWalk plugin does add to boot time, but 10 sec is ridiculous.

@luchillo17 in Beta12 the Ionic team will introduce AoT. I believe and hope that will improve our loading performances and Iā€™m particularly waiting that release.

But till then, like the famous philosopher, Jon Bon Jovi, said, I ā€œKeep the faithā€ :slight_smile:

Iā€™ve been trying to optimize my bundle, thanks to webpacks analyze page i got this graph of deps, then i notice that for ionic-angular components iā€™m not using half of them, for example the infinite-scroll component i donā€™t need it:

image

But ionic add it by default so i will have to resort to webpack to block some components of being included in the bundle, anyone knows a better approach?

Take as example this How to prevent moment.js from loading locales with webpack? post in stack overflow that shows how to tell webpack to only import a few allowed locales instead of the whole range (i use only ā€˜enā€™, but there are 1 locale per country or so), however idk how to do something like that with ionic since it doesnā€™t have a dynamic import but a named import, any toughs on this?

@mhartington In this regard how will optimization work in the future? will we need to import each component we need in order to opt in only the needed components? as far as i see all those components and directives are being imported by the ionicBootstrap method, so we have no control over the imports inside ionic, i think we can say the same about Angular but in recent versions (RC.5) we are presented with modules that allow to specify the imports so we only import what we need and nothing else.

4 Likes

I have read such article http://www.sherpadesk.com/optimizing-our-mobile-ionic-2-angular-2-speed-up-the-initial-loading-time/ regarding this
But features mentioned there donā€™t really change the situtation, so I still have 3MB of app.bundle.js and the app is still loading 8-10 seconds.

Anyone succeeded in making start of the app faster than 5 secs?

Nope, i think in my case itā€™s mostly the fault of the plugins which makes the app very heavy, at the time my app ends up with 92 Mb size in the actual device.

I know most of this is because iā€™m using XWalk and maybe other plugins like CordovaSqlite, since my app itself getā€™s to weight 1.5 Mb after three shaking, UglifiJS doing unreachable code removal and minification, i think the slow part in the app startup is the plugin load itself.

But I tried everything from the web which is somehow related to speeding up boot time of ionic 2 and have no result. Currently the app still loads for ~10 secs before start and there is no additional plugins installed, I have tried to install XWalk recently and it made no impact on the boot time of the app. The only thing I found was that I can show a splashscreen during the boot and fade it after that but 10 secs are too long anywayā€¦

@mhartington which boot time Ionic team expect from the app currently? I read your answer above and Iā€™m just trying to understand is it usual situation and maybe will be changed to better later or maybe I made smth wrong.

In my case is still 10+ sec so after a lot of optimizations i still think it is either the Cordova Plugins that take that much or Cordova itself that loads too slow.

Also note that XWalk will help a lot in performace in older or lower spec devices, in recent ones thereā€™s no perceivable difference, and it does not help with boot time but with general app performance and compatibility issues.