Agr
Agr

Reputation: 57

Angular 2 long app loading

I have problem with long loading angular 2 app, it takes almost 8 seconds. I noticed that the most time takes loading rxjs. There are tens of requests to rxjs/observable rxjs/add rxjs/operator

What can i do to improve my app loading?

Upvotes: 0

Views: 127

Answers (1)

iamthes
iamthes

Reputation: 125

If you are using systemjs as module loader.

  1. Including bundled versions, angular related modules comes with umd bundles. Part of systemjs.config.js:

    var umdPackages = [
     "@angular/common",
     "@angular/compiler",
     "@angular/core",
     "@angular/http",
     "@angular/platform-browser",
     "@angular/platform-browser-dynamic",
     "@angular/router",
     "@angular/testing"
    ];
    umdPackages.forEach(function(name) {
      var main = name.slice(name.lastIndexOf("/") + 1) + ".umd.js";
      packages[name] = { main: main, format: "amd", defaultExtension: "js"};
    });
    

    It will reduce requests by ~300.

  2. In theory, same possible for rxjs. There are bundles umd and system.register. But it doesn't work, loading still happens one by one file (for rxjs) - isFunction.js, Observer.js, etc.

Upvotes: 1

Related Questions