How it works...

The idea of lazy loading is the same as any other type of technology. However, the implementation of Ionic is very different, even if you compare it with Angular's lazy loading.

First, you need to create a feature module for the Ionic Page that you want to lazy load. In our case, we created home.module.ts. It looks as follows:

import { NgModule } from "@angular/core";import { IonicPageModule } from "ionic-angular";import { HomePage } from "./home";@NgModule({ declarations: [HomePage], imports: [IonicPageModule.forChild(HomePage)]})export class HomePageModule {}

It's a feature module where a declarations array has HomePage, and we use the IonicPageModule.forChild method in the imports array with HomePage as an input to it so ...

Get Ionic Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.