Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can angular polyfills.ts file be safely removed

Now that angular is working with Ivy and decided to abandon internet explorer.

Shall we safely remove the polyfills.ts file in our Angular >= v13 project?

like image 250
Raphaël Balet Avatar asked Jan 24 '26 08:01

Raphaël Balet


1 Answers

Angular <=14

According to the docs, Angular has a mandatory polyfill for zone.js. Without this polyfill, your application may not work. So it is not safe to remove the polyfills.ts file.

Angular 15+

Apparently, in Angular v15 the polyfills.ts file is not anymore being added to new projects when using the ng new command, see the updated docs. So after updating to Angular 15, you may be able to remove the polyfills.ts file, if it only contains the zone.js import. However, in this case you will need to add the polyfill via angular.json:

"polyfills": ["zone.js"]

Angular 18+

Since Angular 18, applications can go zoneless, which makes ZoneJS obsolete. Once the zoneless mode is activated with provideZonelessChangeDetection() (or before Angular 20 provideExperimentalZonelessChangeDetection()), the zone.js polyfill needs to be removed. In zoneless applications, no polyfills are necessary.

like image 81
JSON Derulo Avatar answered Jan 26 '26 23:01

JSON Derulo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!