28
loading...
This website collects cookies to deliver better user experience
polyfills.ts
file. With the introduction of Angular CLI 7.3 we get conditional polyfills, where we only ship the older polyfills to pre-ES2105 browsers. This results in a savings of about 56Kb. This won’t take you from average to superhero load times, but this is an easy optimization.ng new
away!polyfills.ts
angular.json
npm uninstall -g @angular/cli
npm install -g @angular/cli
ng update @angular/cli @angular/core
package.json
, but you may need to make a few more.polyfills.ts
file:angular.json
under your project in architect/build/options
:"es5BrowserSupport": true
ng build
dist
folder under your project name you should find a new es2015-polyfills.XXX.js
file. This is the file that will be conditionally loaded if the browser requires those polyfills.index.html
from your project’s dist
folder and look down at the bottom. The following script tags were added by the builder to your index.html during compilation (I’ve formatted these for the purpose of this article):nomodule
attribute on the es2105-polyfills line. The HTML spec for nomodule
says:The nomodule
attribute is a boolean attribute that prevents a script from being executed in user agents that support module scripts.
nomodule
on a script tag, any evergreen browser which supports modules is going to ignore that script. So, your older browsers will download this, but the newer ones will not. This will save you about 56Kb on startup!