DatePicker performance regression from v20 to v21
Describe the bug
There is a significant performance regression in the DatePicker component when upgrading from PrimeNG v20 to v21. Rendering multiple DatePicker instances is noticeably slower in v21.
Pull Request Link
No response
Reason for not contributing a PR
- [x] Lack of time
- [x] Unsure how to implement the fix/feature
- [ ] Difficulty understanding the codebase
- [ ] Other
Other Reason
No response
Reproducer
https://stackblitz.com/~/github.com/lukedays/primeng-datepicker-v20
Environment
Windows 11, Chrome 143
Angular version
21.0.2
PrimeNG version
v21
Node version
24.11.1
Browser(s)
Chrome 143
Steps to reproduce the behavior
PrimeNG/Angular 20 (baseline)
- Clone the Angular 20 version: https://stackblitz.com/~/github.com/lukedays/primeng-datepicker-v20
- Run
npm install - Run
npm test - Observe the rendering time in the console
PrimeNG/Angular 21 (performance issue)
- Clone the Angular 21 version: https://stackblitz.com/~/github.com/lukedays/primeng-datepicker-v21
- Run
npm install - Run
npm test - Compare the rendering time with Angular 20
Note: I couldn't make the Angular 21 version work on StackBlitz due to LMDB compatibility.
Expected behavior
The DatePicker component should render with similar performance in both Angular 20 and Angular 21. The rendering time should not significantly increase between versions.
+1 Have a table using 2 Datepickers on each row and render times have gone from ~1 seconds to 5 seconds now using virtual scroll showing 20 at a time without changing anything except for upgrading to ngprime21.
I noticed the same issue after updating to version 21 DatePicker rendering has become much slower.
Yupp, I'm having the same issue, that rendering a component with datepickers is very slow...
+1
We've noticed the same issue after upgrading to v21.
Hello! Any news on this? Thanks in advance.
+1 Have a table using 2 Datepickers on each row and render times have gone from ~1 seconds to 5 seconds now using virtual scroll showing 20 at a time without changing anything except for upgrading to ngprime21.
I have exactly same scenario, Rendering 250 rows with two datepickers each takes about 10 seconds. When replaced with native html5 datepicker about 2 seconds. Accidentally tracked it down to primeng.
It looks like the full calendar view is rendered when the datepicker is initialized, then immediately removed from the DOM until it is actually shown by the user. In my tests the initial calendar renders 3 times per datepicker.
I found a workaround that avoids rendering the calendar by setting the property timeOnly to true, and changing it to false onShow. This probably helps because the timeonly-form is lighter.
<p-datepicker [timeOnly]="timeonly()"
(onFocus)="timeonly.set(false)"
(onShow)="timeonly.set(false)"/>