Ionic 2 enableProdMode()

Ionic 2 uses Angular 2 ,the next version of the popular Google client side framework .Angular 2 is more powerful than Angular.js and provides more performance and speed on mobile and desktop .

In development phase ,Angular 2 works on development mode which has assertions and various necessary framework checks turned on .

After serving your Ionic 2 app using the browser ,if you look on the console you are going to find an Angular 2 message telling you that Angular 2 is running on development mode and that you need to enable the production mode using enableProdMode() function .There is a good reason for this so if you just enable Angular 2 production mode you are going to :

  • Have a good boost on performance and speed of your Ionic 2 app :the device ready event will fire much sooner
  • Reduce the app size by half .

How to enable Angular 2 production mode ?

To enable Angular 2 production mode in Ionic 2 we use the enableProdMode() function .Here is a detailed example on how to do it .

First of all, open src/app/main.ts

Then import enableProdMode from Angular 2 core

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

import { AppModule } from './app.module';

Then call the enableProdMode() function before bootstraping your module




So that is all for this short tip tutorial where I just showed you how to enable Angular 2 production mode on Ionic 2 when you are ready to build and publish your mobile app to increase performance and speed ,and reduce app size .

Note: We also publish our tutorials on Medium and If you prefer reading in these platforms, you can follow us there to get our newest articles.

You can reach the author via Twitter:

About the author

Ahmed Bouchefra
is a web developer with 5+ years of experience and technical author with an engineering degree on software development. You can hire him with a click on the link above or contact him via his LinkedIn account. He authored technical content for the industry-leading websites such as SitePoint, Smashing, DigitalOcean, RealPython, freeCodeCamp, JScrambler, Pusher, and Auth0. He also co-authored various books about modern web development that you can find from Amazon or Leanpub

Get our Learn Angular 8 in 15 Easy Steps ebook in pdf, epub and mobi formats, plus a new Angular 8 tutorial every 3 days.

comments powered by Disqus Protection Status