perf: Slow load when pages are loaded the first time
Type: perf
Ionic Version: 2.x
Platform: android 4.4 webview
Even though a page is very simple, the first page load is delayed. This looks strange - also compared to other UI frameworks. Once loaded, the next page load is fast. IMO this should be optimised.
The issue can be reproduced by adding some HTML content to the empty pages of the starter app with tabs. You have to test on a mid range device.
Nexus 4, Android 4.4 prodMod: true gulp build --release Android release build
Thanks!
Hey @rdesimone ! This is by design, we lazy load our components, so the first load is always gonna be the slowest, but after that first load it should be fast. If you would like to "preload" all your tabs you can add the preloadTabs attribute to your ion-tabs components and set it to true. http://ionicframework.com/docs/v2/api/components/tabs/Tabs/ Be aware that this may make the first app load slightly slower if you have alot of dom elements as the app will load all your tabs up front instead of lazy loading them. Thanks for using Ionic!
@jgw96 thanks, I am not talking particularly about tabs. As you confirmed - the first page load is slow by design. With this feature request I want to suggest to optimize the first page load. An app has to be fast. The delay is disturbing. If you are not able to improve, it is a different story. But keep the feature request open to know that somebody addressed this issue.
Sorry i misunderstood you, but very glad to talk about overall first render performance! So are eventual goal, which we are currently working on now, is taking advantage of Angular Universal to create an App Shell that will make Ionic 2 apps load lightening fast. From my testing with the excellent (but still a work in progress) Angular Mobile Toolkit, the first render with Angular Universal is so fast that you literally almost cant see the page load. So once we implement this, along with tree shaking in our build process to make apps smaller, you can expect to see much improved first render time. We care very much about time to first render performance, as its crucial on mobile (and even desktop), so we are working hard on this. Thanks for all your input!
@jgw96 very glad to read your comment! Yes, this is absolutely necessary.
Again we have a misunderstanding - LOL. Your comment addresses the issue we have in CLI https://github.com/driftyco/ionic-cli/issues/1010 . In this issue I am talking about the first load of any page. Every time a user selects a page for the first time, there is a delay which is disturbing. If possible this should be optimized. Thanks!
Sorry, actually i was talking about this issue too, although it definitely ties in to our other issue (: So once we get a better build process including offline compile etc, along with angular universal and the app-shell concept working, i think you will see not only first render, but navigating between pages being much faster.
LOL - no problem!
I am a little bit scared about the timeframe but everything sounds very nicely!
@jgw96 I didn't see the integration with Universal in the roadmap, though I have read it is in many places. Any ideas which can be shared?
To be frank, I am sitting here trying to decide if Ionic2/Angular2 is the right direction for our next line-of-business application. The only reserve I have is if the solution downloads the entire webapp for just a single page hit, what would our bandwidth cost be from our hosting provider? Or should be go with straight ASP.NET Core 1.0 with responsive design? It appears, though I am not clear, that Universal still eventually downloads the entire website after initial load. Is that true?
There is a lot of talk about how Universal will be great from the client perspective, I have not found any comments on the impact to bandwidth costs with ISP's for the SaaS provider. Bandwidth is a very large cost aspect.
Thanks for your insight.
Hey @VR-Architect you are correct about not seeing it on the roadmap, it is still very early in consideration. The first thing we want to focus on is getting our size down. Currently Ionic 2 is relatively big, but we have some ideas like offline template compile, aggressive minifying etc, which we are wanting to implement relatively soon. This would help with both @rdesimone's and your issue pretty tremendously as you would be sending less over the network to start with. However for a "quicker" solution for your issue, i have an idea. I would consider taking a look at service workers. Service workers allow you to cache all your assets on the client so that next time the user opens your app, they will not have to pull assets down from your servers again unless you, the dev, make a change to your service worker and push it out. With this implemented it would most likely cut down on your bandwith usage by a huge percentage as, like i said, your users would only have to pull down the whole app once. This also gives you the pretty awesome side effect of your app loading just as fast on a slow mobile connection as it does on a google fiber connection. As far as Angular Universal goes, we are looking at implementing that to get an ultra fast first render for ionic apps. What were looking to do with Universal is to load a cached "app-shell" to the user that can be loaded in milliseconds, while the actual application loads a few seconds later. This gives the user the impression that the app has loaded lightning fast, even though the app is still working on loading in the background. So, based off of what were going to user Angular Universal for, and the fact that the app-shell i described is going to be cached, i think this will not hurt your bandwith usage in any significant way. You can see that an example of a service worker enabled Ionic 2 application here. If you watch the console you can see that it caches all the assets of the app when you first load and use the application, and then the next time you load up the app it will pull all those assets from cache instead of the network. Also, as i said above, this app will work completely offline (except for google maps of course). So feel free to turn on airplane mode and reload the app. If everything works like i designed it, it should reload just as if you were online (: Finally, feel free to take a look at the code for it here and take a look at how i am doing the service worker. It is a slightly modified recipe i got from this repo. Sorry for how long this answer is, but i hope it helps you with your decision. Thanks for using Ionic!
@jgw96 Thanks for the excellent information about the bandwidth! Guess I will stay with Angular 2 rc1 and when Ionic 2 split pane comes out, we will migrate the code.
It seems that android version is important to consider. I tried with two identicals phones but with a different Android version. With my app, the phone with Android 4.4.2 is much slower than the phone with Android 5.1.1
It's important that Kikat Android version have a good performance. As you can see here, Android Kitkat4.4 is mostly used.
@hamark I would recommend you to consider using Crosswalk. See the following topic for more details. And, on a side note, here are up-to-date Android usage statistics: Android Developer Dashboards.
This behaviour is also noticeable in a packed Android App (with Cordova).
Are there any new suggestions ho the resolve this issue? Thanks
@hamark Using Crosswalk resolved this issue for you?
Hello all! I am going to be closing this issue in favor of https://github.com/driftyco/ionic/issues/6776 as that one is more up to date. Feel free to follow the progress there!
Why you closed this issue. Is this issue resolved? This is the very big issue. Is app first time load slow the user think this is meaningless app
@grana601 Hello! I closed this issue to consolidate it into #6776. That issue is more updated than this one. Sorry for any confusion. Thanks for using Ionic!
Sorry to ask here, but I read you mention about Tabs component. I'm getting slowness issues because of the amount of elements in tabs. Is there a way I can delete the loaded page inside the last tab so when I'm coming back to that tab it would act as a new one? (loading the contents again). Thank you.
Crosswalk adds 18MB to app size. Which is too much.
This works,
https://forum.ionicframework.com/t/ionic-2-speed-up-boot-time/46372/134
Using crosswalk allows apps with less android version 4.2.2 downwards or low perfomance load your app but it doesnt solve the problem of slow loading at first launch