Full answer
Start by measuring. Use the browser Performance panel while typing in a field, and the Angular DevTools profiler. Look for long tasks per keystroke, and check which components are checked and which functions are slow (validators, template methods, valueChanges subscribers). Without that, you may optimise the wrong thing.
Typical causes and fixes:
- Every change triggers heavy work. By default, a control updates on each
inputevent: it runs validators, updates its parent group (which runs the group validator and recalculates validity up to the root), and emitsvalueChangesandstatusChanges. With hundreds of controls, a group validator or a rootvalueChangessubscriber that loops over everything is expensive. Fixes:updateOn: 'blur'(or'submit') for the form, group or specific controls, so work happens once when the user leaves a field. Debounce expensive reactions withdebounceTime. Avoid subscribing toform.valueChangesfor the whole form, and subscribe to the control that matters. - Validators are slow or call servers. Keep synchronous validators cheap. Async validators should be debounced (
timerin the validator) and run only if the sync validators pass. - Change detection checks everything. Split the form into sub-form components, each with
OnPush, and pass the childFormGroupdown. WithControlContainer(viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }]) sub-components can useformControlNameinside the parent form. A keystroke in one section then only checks that section. - Template methods and getters. A method like
getError('email')that callsform.get(...)many times per check adds up. Use direct control references (form.controls.email),@let, or computed values, and show errors only for touched controls. - Many rows. In a
FormArrayof hundreds of rows, usetrackon a stable id, virtual scrolling for the rows that are visible, or pagination. Create row groups lazily. - Too much on the page. Split a long form into steps or accordions rendered on demand (
@defer,@if). Autosaving the form can use a debounced write, not an immediate write per key. - Template-driven forms with
ngModelon hundreds of inputs are slower than reactive forms because each control registers asynchronously. Prefer reactive forms for large screens.
After each change, measure again with the same typing test. Keep the gains with a small performance test or a budget in review.
typescript
import { Component } from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
// Captured in Karma (Angular 20.3): three input events, then one blur
// default controls: valueChanges emissions while typing = 3, after blur = 3
// updateOn 'blur': valueChanges emissions while typing = 0, after blur = 1
export const counts = { change: 0, blur: 0 };
@Component({
selector: 'app-update-on-demo',
imports: [ReactiveFormsModule],
template: `
<input id="a" aria-label="Default" [formControl]="onChange" />
<input id="b" aria-label="On blur" [formControl]="onBlur" />
`,
})
export class UpdateOnDemoComponent {
readonly onChange = new FormControl('', { nonNullable: true });
readonly onBlur = new FormControl('', { nonNullable: true, updateOn: 'blur' });
constructor() {
this.onChange.valueChanges.subscribe(() => counts.change++);
this.onBlur.valueChanges.subscribe(() => counts.blur++);
}
}Angular 20.3, strict template check passes. A Karma test sends three input events to a field and counts valueChanges emissions for the default setting and for `updateOn: 'blur'`: 3 and 0 while typing, and 1 after blur (the captured numbers are in the comment).
Key points
- Profile typing first. Look for validators, `valueChanges` subscribers and wide change detection.
- Reduce work per keystroke with `updateOn: 'blur'`, debounce, and narrow subscriptions.
- Split into `OnPush` sub-form components using `ControlContainer`. Use `track`, virtual scroll or steps for big lists.
- Prefer direct control references over template methods, and reactive over template-driven forms for big forms.
Common mistakes
- Subscribing to the whole form's `valueChanges` to do heavy work.
- Optimising without a profile.
- Rendering all rows of a huge `FormArray` at once.
Follow-ups
- What does `updateOn: 'blur'` change for validation messages?
- How does `ControlContainer` let a child component join the parent form?
- When would you split the form into steps?
Tips
- Start with measuring.
- Group the causes: work per key, check scope, and size.
- Mention a measurable test after the fix.
Evaluation rubric
- Finds causes through profiling.
- Gives targeted fixes for validation, change detection and size.
- Verifies with measurement.