How can I decrease the Ionic Cordova Project Start duration ?

久未见 提交于 2019-12-12 13:37:10

问题


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



来源:https://stackoverflow.com/questions/46139512/how-can-i-decrease-the-ionic-cordova-project-start-duration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!