Hi,
So I just spent every night for two weeks to migrate my app from V3 to V4. I have mixed feelings about this… And wonder if I need to tweak some more things.
Because right now, the performance has been really degraded from v3 to v4 ! I mean :
Total initial boot time
v3 : 6s
v4 : 10s
hot reload with serve
v3 : 2 - 3s
v4 : 12 - 15s
(I saw many recommandations regarding this issue, to go and install Node v10 for example… Will try it out tonight)
Loading my biggest page (.ts file is approx. 450 lines)
v3 : ~2s
v4 : ~5s !!!
Add to this, overall performance feels more sluggish. For example, going from tab1
to tab2
has a small delay that feels a little slower than v3. Also, elements in the page that triggers navigation seems to take a little more time before triggering - ion-button
or ion-fab-button
don’t need tappable
property, right ?
So, it was not hard to migrate but a real hassle, as it was expected - but I did it in good faith, thinking I would improve my app performances. Either I was wrong to think this, or there are some more things to do in order to obtain the desired result - in case it should be documented in the migrating guide ( I followed every step and every single point of the Breaking changes
.)
Now, let’s ask some questions with some code !
app-routing.module.ts :
const routes: Routes = [
{ path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'home', loadChildren: './pages/home/home.module#HomePageModule' },
{ path: 'detail/:id', loadChildren: './pages/detail/detail.module#DetailPageModule' },
.....
];
@NgModule({
imports: [RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })],
exports: [RouterModule]
})
export class AppRoutingModule {}
First things first, could PreloadAllModules
be one of the problematic points ? In Ionic v3 I wasn’t using Lazy Loading much, only for a few pages, so I decided to follow recommandations when migrating and everything is lazy loaded now if I did things right - but I told myself, PreloadAllModules
should be the right bet to get both faster boot time and still good performance when opening a page.
tabs.router.module.ts :
const routes: Routes = [
{
path: 'app',
component: TabsPage,
children: [
{
path: 'home',
children: [ { path: '', loadChildren: '../pages/home/home.module#HomePageModule' } ]
},
{
path: 'my-list',
children: [ { path: '', loadChildren: '../pages/my-list/my-list.module#MyListPageModule' } ]
},
{
path: 'actions',
children: [ { path: '', loadChildren: '../pages/actions/actions.module#ActionsPageModule' } ]
},
{
path: '',
redirectTo: '/app/home',
pathMatch: 'full'
}
]
},
{
path: '',
redirectTo: '/app/home',
pathMatch: 'full'
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}
This routing is imported to be used used by TabsPageModule
. I know what you could say - “you should add children to your tabs so the navigation stack works.”. The format is just like I want it - having main pages in tabs but when navigating to another page, falling back to the main router. It works… It’s just slow.
The rest of the app is mostly the same as it was in V3 - except I took a lot of time to migrate my scss to css4 variables, which in fact reduced my overall custom styles.
I would take any advice on how to test and check what is causing the app to slow down as well.
Thanks and good luck !