Trying to limit library file size by loading only some directives


#1

Hi,

I’m trying to find a workarond for the huge Ionic2 library size (3.0 MB)uncompressed) by loading only the directives I use, but even loading a button triggers the whole framework:

import {
  ionicProviders,
  Platform,
  Button
} from 'ionic-angular';

var directives = [
  CORE_DIRECTIVES,
  FORM_DIRECTIVES,
  Button
}

@Component({
  directives: directives,
  ...
})

Is there any better way to do this, or is my idea just plain wrong? Also, does anyone have another idea to limit the filesize? I minify it and all, but even then it takes 1.2mb which means 4s loading time on Android :frowning:

Best,
Marek


#2

This doesn’t make any difference, as you already discovered, because all directives are loaded by default (and this is currently the expected behavior):

AFAIK currently there’s no way to achieve this. But your idea is very valid, especially for the mobile web. I’m also looking forward for such a possibility because it will make the use of the Ionic framework in (mobile) web applications reasonable (and justifiable).

Check out the following post for more details about the Ionic’s PWA efforts: