Search performance improvement
Avoid calling the search for each keypress. It will make browser unresponsive. Call search on timeout. That is when user stops typing for 500 millisecond Change-Id: I93a0e5c5d1035463be9a25047134b042f6743fb8
This commit is contained in:
@@ -35,6 +35,14 @@
|
||||
this.listen();
|
||||
};
|
||||
|
||||
var delay = function() {
|
||||
var timer = 0;
|
||||
return ( function( callback, milliseconds ) {
|
||||
clearTimeout( timer );
|
||||
timer = setTimeout( callback, milliseconds );
|
||||
} );
|
||||
}();
|
||||
|
||||
LanguageFilter.prototype = {
|
||||
|
||||
listen: function() {
|
||||
@@ -57,8 +65,11 @@
|
||||
this.options.$target.focus();
|
||||
}
|
||||
default:
|
||||
this.options.$target.empty();
|
||||
this.search();
|
||||
var that = this;
|
||||
delay( function() {
|
||||
that.options.$target.empty();
|
||||
that.search();
|
||||
}, 500 );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user