After releasing our first ionic app, we were surprised with the size of the final APK / IPA. After some research we found that the
www/lib folder was eating 12 MB. It seems that by default, ionic / cordova will copy the whole www/lib to the final APK.
The problem is that in the
www/lib there are a lot of unnecessary files, and there is no “best practice” for solving this prbolem.
For instance, Ionic always comes with:
├── ionic-angular.js ├── ionic-angular.min.js ├── ionic.bundle.js ├── ionic.bundle.min.js ├── ionic.js └── ionic.min.js
But actually, only the
ionic.bundle.js will be referenced in the index.html:
If we take a look to that file we see this:
/*! * ionic.bundle.js is a concatenation of: * ionic.js, angular.js, angular-animate.js, * angular-sanitize.js, angular-ui-router.js, * and ionic-angular.js */
So it seems this includes all we need for a basic ionic app. The other files are totally unnecessary but they will be still copied to the final APK / IPA.
The problem gets a little bit worse if we add some more bower components to our project. Let’s say we add
angular-translate. This obviously depends on
angular to work. However doing
bower install, bower won’t realize we already have
angular (bundled by
ionic) and it will install a copy of
www/lib which will eat another 1MB.
So, my questions (probably for Ionic team) are:
- Why does the
ionicbower package come with
angularinstead of defining it as a dependency?
- Are there any plans for defining a best practice for cleaning out the raw libraries from the final builds?
Thank you in advance!