r61563 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61562‎ | r61563 | r61564 >
Date:07:45, 27 January 2010
Author:werdna
Status:ok
Tags:
Comment:
LiquidThreads: replace some inefficient direct Sizzler ($j(selector)) calls with smarter logic, improves performance on large, slow-loading pages.
Modified paths:
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/lqt.js
@@ -657,20 +657,34 @@
658658
659659 // Update thread-level menu, if appropriate
660660 if ( $j(threadWrapper).hasClass( 'lqt-thread-topmost' ) ) {
 661+ // To perform better, check the 3 elements before the top-level thread container before
 662+ // scanning the whole document
 663+ var menu = undefined;
661664 var threadLevelCommandSelector = '#lqt-threadlevel-commands-'+threadId;
 665+ var traverseElement = $j(threadWrapper);
662666
663 - var menu = $j(threadLevelCommandSelector);
 667+ for( i=0;i<3 && typeof menu == 'undefined';++i ) {
 668+ traverseElement = traverseElement.prev();
 669+ if ( traverseElement.is(threadLevelCommandSelector) ) {
 670+ menu = traverseElement
 671+ }
 672+ }
 673+
 674+ if ( typeof menu == 'undefined' ) {
 675+ menu = $j(threadLevelCommandSelector);
 676+ }
 677+
664678 liquidThreads.setupThreadMenu( menu, threadId );
665679 }
666680
667681 // Check for a "show replies" button
668 - $j('a.lqt-show-replies').click( liquidThreads.showReplies );
 682+ $j(threadContainer).find('a.lqt-show-replies').click( liquidThreads.showReplies );
669683
670684 // "Show more posts" link
671 - $j('a.lqt-show-more-posts').click( liquidThreads.showMore );
 685+ $j(threadContainer).find('a.lqt-show-more-posts').click( liquidThreads.showMore );
672686
673687 // Handler for "Link to this" button
674 - $j('.lqt-command-link').click( liquidThreads.showLinkWindow );
 688+ $j(threadContainer).find('.lqt-command-link').click( liquidThreads.showLinkWindow );
675689 },
676690
677691 'showReplies' : function(e) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r61564Merge r61563 to LiquidThreads production deploymentswerdna07:49, 27 January 2010
r61565Merge r61563 to LiquidThreads test deploymentswerdna07:52, 27 January 2010

Status & tagging log