Cling
Cling

Reputation: 499

angular2 slow in IE and usage of core-js

I see the angular2 app that I created is much slower (approximately ~5X) in IE11 when compared to other browsers. In IE11, right from the data rendering in a grid, dropdown, pagination are slow whereas the same is super fast and working as expected in other browsers. When I googled, I see using core-js and using enableProdMode() might improve the performance in IE. I have enabled enableProdMode() but I am not clear how to wireup core-js with the angular2 app. I have included core-js as dependency and installed it. So what would be next step to wireup things.?

Upvotes: 2

Views: 6632

Answers (3)

sabithpocker
sabithpocker

Reputation: 15558

My issue in angular 6 was an input binding done to a function:

<app-my-component [model]="getMyModel()"></app-my-component>

I changed that to a variable instead

<app-my-component [model]="valueOfGetMyModel"></app-my-component>

This simple change fixed a major performance issue for me. Also, the function was using a polyfilled function in IE, while other browsers had native implementation that didn't show any notable issues.

As a final fix, I also changed the changeDetection strategy to onPush as this component has 15 instances in the page.

Upvotes: 3

Cling
Cling

Reputation: 499

Including the following libraries as part of polyfills.ts made my application faster but it never matched the performance to Chrome.

import 'core-js/client/core';
import 'zone.js/dist/zone';
import 'rxjs/bundles/Rx';
import '@angular/core/bundles/core.umd';
import '@angular/common/bundles/common.umd';
import '@angular/compiler/bundles/compiler.umd';
import '@angular/platform-browser/bundles/platform-browser.umd';
import '@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd';`

Beware, adding these files increases the size of the bundle drastically.

Upvotes: 0

Senthil Ramadoss
Senthil Ramadoss

Reputation: 1

please create angular project using angularcli commondline

use ng build --prod to compile your angular project

This will work IE same as Chrome. I have tested and working like charm in my application

Upvotes: 0

Related Questions