jenkins-bot has submitted this change and it was merged.

Change subject: ve.ui.SpecialCharacterPage: Use less jQuery for better 
performance
......................................................................


ve.ui.SpecialCharacterPage: Use less jQuery for better performance

Slashes runtime of ve.ui.SpecialCharacterDialog#buildButtonList
by about 80-90%.

Bug: T96456
Change-Id: I41d3bcb1199c6ed7cb15a48e325fe7a14045b04f
---
M src/ui/pages/ve.ui.SpecialCharacterPage.js
1 file changed, 10 insertions(+), 8 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ui/pages/ve.ui.SpecialCharacterPage.js 
b/src/ui/pages/ve.ui.SpecialCharacterPage.js
index ba5ec82..1e2cc01 100644
--- a/src/ui/pages/ve.ui.SpecialCharacterPage.js
+++ b/src/ui/pages/ve.ui.SpecialCharacterPage.js
@@ -22,17 +22,19 @@
        this.label = config.label;
        this.icon = config.icon;
 
-       var character,
+       var character, characterNode,
                characters = config.characters,
-               $characters = $( '<div>' ).addClass( 
've-ui-specialCharacterPage-characters' );
+               $characters = $( '<div>' ).addClass( 
've-ui-specialCharacterPage-characters' ),
+               charactersNode = $characters[0];
 
+       // The body of this loop is executed a few thousand times when opening
+       // ve.ui.SpecialCharacterDialog, avoid jQuery wrappers.
        for ( character in characters ) {
-               $characters.append(
-                       $( '<div>' )
-                               .addClass( 
've-ui-specialCharacterPage-character' )
-                               .data( 'character', characters[character] )
-                               .text( character )
-               );
+               characterNode = document.createElement( 'div' );
+               characterNode.className = 
've-ui-specialCharacterPage-character';
+               characterNode.textContent = character;
+               $.data( characterNode, 'character', characters[character] );
+               charactersNode.appendChild( characterNode );
        }
 
        this.$element

-- 
To view, visit https://gerrit.wikimedia.org/r/204976
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I41d3bcb1199c6ed7cb15a48e325fe7a14045b04f
Gerrit-PatchSet: 4
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to