Skip to content

Improve localTimeAgo rendering

Tim Zallmann requested to merge 56327-improve-localtimeago-rendering into master

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?

Does this MR meet the acceptance criteria?

Closes #56327 (closed)

Edited by Lukas Eipert

Merge request reports