How can I decrease the Ionic Cordova Project Start

2019-07-04 08:25发布

问题:

I made a ionic cordova project but after publishing to android mobile phone. The duration of our program is around 10-20 sec with respec to the mobile phone types.

When I search this problem, people say that it is because of

  1. Splash Screen duration (Ionic splash screen not loading and Ionic2 performance issue)
  2. Path problem of any image
  3. 3rd Party libraries
  4. External CDN script libraries
  5. Lazy loading of pages

I try to solve regarding above problems e.g. i removed 3rd party libraries or CDN based scripts and check the all image paths etc..

I think Ionic is a wrong choice for mobile programming.

Is there any solution to decrease the opening duration of my mobile application ?

Thanks

回答1:

The all other answers are also necessary but I want to add another opinion.

If u use IONIC 3 you can try lazy loading and discard unnecessary 3rd party libraries like awesome or another...

This new feature from Ionic 3 not only makes our code more concise but also avoid the hassle of typing every damn time the same paths in every Class! Lazy Loading allows us to access Pages wherever we want by only using a string.

In old version, u need to use

import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';

@NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  .
  .
  .
  entryComponents: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ]
})

In Ionic 3 u dont need to import these classes. U can use ionic g page example Then we see that a @IonicPage decorator and a module with a same name in the directory.

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { Lazy } from './example';
@NgModule({
  declarations: [
    Example,
  ],
  imports: [
    IonicPageModule.forChild(example),
  ],
  exports: [
     Example
  ]
})
export class ExampleModule {}

This pages or components could not be loaded while starting program.



回答2:

Add these line to you main.prod.ts file.

import { enableProdMode } from '@angular/core';
enableProdMode();

and then build using this command

ionic cordova build android --prod --release


回答3:

Ionic is the perfect solution for mobile app development.You need to use right CLI for that. Use below one:

debug mode: This CLI supports AOT

ionic cordova run android --prod --device

release mode:

ionic cordova build android --prod --release

You can see this CLI list here