Skip to content

Commit 8177ec4

Browse files
committed
Shave another 200-300ms off the 400 listview item page by simply reducing the number of function calls we make during enhancement.
- Got rid of _itemApply() and moved it's functionality to the bottom of refresh(), doing finds from $list where we can, and li where we can't. Boom, at least 1200+ less function calls.
1 parent 4cee7ad commit 8177ec4

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

js/jquery.mobile.listview.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ $.widget( "mobile.listview", $.mobile.widget, {
3535
t.refresh( true );
3636
},
3737

38-
_itemApply: function( $list, item ) {
39-
var $countli = item.find( ".ui-li-count" );
40-
if ( $countli.length ) {
41-
item.addClass( "ui-li-has-count" );
42-
$countli.addClass( "ui-btn-up-" + ( $list.jqmData( "counttheme" ) || this.options.countTheme ) + " ui-btn-corner-all" );
43-
}
44-
45-
// TODO class has to be defined in markup
46-
item.find( ">img:eq(0), .ui-link-inherit>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
47-
item.addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
48-
});
49-
},
50-
5138
_removeCorners: function( li, which ) {
5239
var top = "ui-corner-top ui-corner-tr ui-corner-tl",
5340
bot = "ui-corner-bottom ui-corner-br ui-corner-bl";
@@ -205,17 +192,28 @@ $.widget( "mobile.listview", $.mobile.widget, {
205192
}
206193

207194
item.add( item.children( ".ui-btn-inner" ) ).addClass( itemClass );
208-
209-
self._itemApply( $list, item );
210195
}
211196

212-
$list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ).end()
213-
.find( "p, dl" ).addClass( "ui-li-desc" ).end()
214-
.find( ".ui-li-aside" ).each(function() {
215-
var $this = $(this);
216-
$this.prependTo( $this.parent() ); //shift aside to front for css float
217-
});
197+
$list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" )
198+
.end()
218199

200+
.find( "p, dl" ).addClass( "ui-li-desc" )
201+
.end()
202+
203+
.find( ".ui-li-aside" ).each(function() {
204+
var $this = $(this);
205+
$this.prependTo( $this.parent() ); //shift aside to front for css float
206+
})
207+
.end()
208+
209+
.find( ".ui-li-count" ).each( function() {
210+
$( this ).closest( "li" ).addClass( "ui-li-has-count" );
211+
}).addClass( "ui-btn-up-" + ( $list.jqmData( "counttheme" ) || this.options.countTheme) + " ui-btn-corner-all" );
212+
213+
li.find( ">img:eq(0), .ui-link-inherit>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
214+
var $this = $( this );
215+
$this.closest( "li" ).addClass( $this.is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
216+
});
219217

220218
this._refreshCorners( create );
221219
},

0 commit comments

Comments
 (0)