Make $.fn.updateTooltipAccessKeys() less expensive
authorOri Livneh <ori@wikimedia.org>
Mon, 23 Nov 2015 21:59:21 +0000 (13:59 -0800)
committerOri Livneh <ori@wikimedia.org>
Tue, 24 Nov 2015 05:07:41 +0000 (21:07 -0800)
commit9f581191d20c796bb449151c4643ee941bf8927a
tree17524af05de3788334b924e5c7c0c0398822177f
parent07b407f558fbfdeacde6f10ccabc9130ee6b0e0e
Make $.fn.updateTooltipAccessKeys() less expensive

On page.ready on desktop skins, we call $.fn.updateTooltipAccessKeys(), which
updates about 20 elements (depending on the page and skin). Each invocation
parser the 'brackets' message, which ends up being quite expensive. We
previously had some caching to mitigate the cost, but it was removed in
I955ee61f6.

We can re-introduce caching without re-introducing the bug that I955ee61f6
sought to mitigate by making the astCache property unique to each parser
instance, as suggested in T54042#545717, and by ensuring the message function
is cached.

Change-Id: Ia1b42c70d8fc6ce03c8708f03c2b835942c4ead3
resources/src/mediawiki/mediawiki.jqueryMsg.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js