From d7f7927ec3e3fa489dc7f14c3de6edea5f6381a8 Mon Sep 17 00:00:00 2001 From: NikG Date: Thu, 10 Nov 2022 13:27:28 +0200 Subject: [PATCH] Add caching for language option list items --- src/jquery.uls.lcd.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index d100ae9..858c692 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -55,6 +55,7 @@ this.$element.addClass( 'uls-lcd' ); this.regionLanguages = {}; + this.$languageOptionListItems = null; this.renderTimeout = null; this.$cachedQuicklist = null; this.groupByRegionOverride = null; @@ -79,7 +80,11 @@ * @return {jQuery} */ getLanguageOptionListItems: function () { - return this.$element.find( 'li[data-code]' ); + if ( !this.$languageOptionListItems ) { + this.$languageOptionListItems = this.$element.find( 'li[data-code]' ); + } + + return this.$languageOptionListItems; }, /**