Improve localTimeAgo rendering
What does this MR do?
- Moves Tooltip creation for timeago elements to
requestIdleCallback
- Memoizes localization of timeago
- Removes unneeded class
js-timeago-render
Results:
On a page with 12 js-timeago
instances we can see the following measurements:
Commit | Time spent in localTimeAgo
|
Time spent on localTimeAgo > gettext
|
s__ function calls |
Profile |
---|---|---|---|---|
227ce776 (Baseline) | 20ms | 11ms | 336 calls | 00-profile-227ce776dcd.json.tar.gz |
636c36bb (Moving modal creation to requestIdleCallback) | 15ms | 11ms | 336 calls | 01-profile-636c36bbbfa.json.tar.gz |
6e4dac35 (Memoizing localization) | 3.49ms | 0.4ms | 6 calls | 02-profile-6e4dac3589d.json.tar.gz |
We notice that we had 28 s__
calls per js-timeago instance. This is consistent with the current pattern of retrieving all translations for each js-timeago
by recreating the array over and over. Once we memoize the function, we have a maximum of 28 calls per page. In normal use cases we probably just see 8-10 calls per page.
What are the relevant issue numbers?
- Closes #56327 (closed)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated via this MR -
Tests added for this feature/bug -
Tested in all supported browsers -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process. -
Security reports checked/validated by reviewer
Closes #56327 (closed)
Edited by Lukas Eipert