Skip to content

Enable ChangeDetectionStrategy.OnPush and coalesce event change detections in v13 #21278

@prabh-62

Description

@prabh-62

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Description

As per the performance checklist published, it is recommended to enable ChangeDetectionStrategy.OnPush to make performant angular applications.

❯ npx @angular/cli@12 new web-apps --create-application falsecd web-apps && yarn ng g app admin-console --routing --style scss
  • Edit angular.json and enable ChangeDetectionStrategy.OnPush for all future generated components
    angular_json_change_detection
  • Edit projects/admin-console/src/main.ts and enable ngZoneEventCoalescing as per performance checklist
platformBrowserDynamic()
  .bootstrapModule(AppModule, {
    ngZoneEventCoalescing: true,
    ngZoneRunCoalescing: true,
  })
  .catch((err) => console.error(err));

Describe the solution you'd like

The above mentioned flags should be enabled by default under strict workspace from Angular v13

Describe alternatives you've considered

Just manually enable the flags on all angular projects.

Why I opened this issue?

The inspiration comes from blog posts by Next.js team. Instead of asking developers to enable flags to make apps perform better, the team enables them by default thereby making all Next.js apps faster.
There is an argument, that this change could invalidate some tutorials out there. If that's the case, then angular can never improve the framework and just stagnate itself.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions