Hi guyz,
There are many posts on the the forum regarding Ionic2 and the current subjects “App boot time too slow” or “Speed up boot load time” or “splash screen take too much time” or “taking too much time to load” so I was thinking that I could open a post about the current state and with some current best practices/possibilities.
If you let comments here under with some good inputs, I gonna try to follow and edit the following list.
Current state:
-
Ionic2 app boot time on real devices is currently dependent of the size of your javascript bundle. Bigger your main.js gonna be, slower your startup gonna be, because everything is loaded when you start your app.
-
The Ionic team is aware of these facts and they are working, as far as I know, on two solutions
-
On the build side, they try to introduce algorithms wich should shrink the size of the build
-
For a longer run, for the future, they think and work on the possibility to lazy load the pages (“only loading one or a couple of pages on startup will reduce the start time because not everything will have to be loaded”)
Current best practices:
-
When you build your app, at least for a real device, always use “–prod” in your cmd line (like “ionic build ios --prod”)
-
If you build your app for production release on android, use “–prod” and “–release”. Summarized “–prod” tell the build it should be compressed, “–release” tell cordova the app should be signed (“ionic build android --prod --release”)
-
Try to shrink your app size. For example if you could:
-
Analyze your pages and providers, save code lines. If you see not used codes, delete it. Refactor your codes to find codes you could merge. Like having two methods or pages which are quite the same and having just one at the end which you could be variable with parameters.
-
If you ship your fonts with your app, if you notice that some aren’t used, delete them (I was shipping italic fonts with my app but they weren’t used)
-
Have a look the external libraries you used. Try to find the big ones and if possible, try to replace them with smaller one. And of course if not used, delete them. To analyze your main.js you could use source-map-explorer (once installed, in www/build, run source-map-explorer main.js main.js.map)
I have no pretension but thought that we could summarize some best practices.
Small is beautiful.
P.S.: Plz don’t post here under thought about what should Ionic team do or don’t. My understanding is that they are full aware of the situation and working hard on it. My goal with that post, is to let us find some best practices we could use to achieve the best we could now.