Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277430

Change subject: Lazy-load: Avoid jQuery filter() due to pushStack() memory
......................................................................

Lazy-load: Avoid jQuery filter() due to pushStack() memory

Assigning the result of filter() is the same as chaining.

For chaining support, jQuery has to keep a stack of all previous versions of
the collections so that things like end() and addBack() work as expected.

In general, when maintaining a collection for a long time, avoid jQuery methods
and use a plain array instead. Otherwise it requires jQuery to keep hold of
all previous versions of the array.

Change-Id: I6b0f08f3f32b490110c7faf5c649effdb3818936
---
M resources/mobile.startup/Skin.js
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/30/277430/1

diff --git a/resources/mobile.startup/Skin.js b/resources/mobile.startup/Skin.js
index dc8361b..f7771c3 100644
--- a/resources/mobile.startup/Skin.js
+++ b/resources/mobile.startup/Skin.js
@@ -175,14 +175,14 @@
                 */
                loadImages: function () {
                        var self = this,
-                               $imagePlaceholders = this.$( '#content' ).find( 
'.lazy-image-placeholder' );
+                               imagePlaceholders = this.$( '#content' ).find( 
'.lazy-image-placeholder' ).toArray();
 
                        /**
                         * Load remaining images in viewport
                         */
                        function _loadImages() {
 
-                               $imagePlaceholders = $imagePlaceholders.filter( 
function ( index, placeholder ) {
+                               imagePlaceholders = $.grep( imagePlaceholders, 
function ( placeholder ) {
                                        var $placeholder = $( placeholder );
 
                                        if (
@@ -196,7 +196,7 @@
                                        return true;
                                } );
 
-                               if ( !$imagePlaceholders.length ) {
+                               if ( !imagePlaceholders.length ) {
                                        M.off( 'scroll', _loadImages );
                                        M.off( 'resize', _loadImages );
                                        M.off( 'section-toggled', _loadImages );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b0f08f3f32b490110c7faf5c649effdb3818936
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

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

Reply via email to