Valerii Vasin (valerii) wrote in changelog,
Valerii Vasin
valerii
changelog

[livejournal] r23247: LJSUP-14127: [Friends Feed] Optimize $.f...

Committer: vvasin
LJSUP-14127: [Friends Feed] Optimize $.fn.ljLikes() plugin to perform parsing only likes that are currently on the page at once. Mark elements as used.
U   trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js	2012-11-02 07:22:31 UTC (rev 23246)
+++ trunk/htdocs/js/jquery_fn.js	2012-11-02 08:46:30 UTC (rev 23247)
@@ -523,12 +523,21 @@
 
 		// find elements with lj-likes class
 		likes = this.find('.lj-like')
-			.add( this.filter('.lj-like') );
+			.add( this.filter('.lj-like') )
+			// filter all previously used elements to prevent double parsing
+			.filter(function () {
+				return !this.used;
+			});
 
 		if (likes.length === 0) {
 			return this;
 		}
 
+		// mark all items as used
+		likes.each(function () {
+			this.used = true;
+		});
+
 		if ( !opts.lazy ) {
 			// not lazy: immediately parsing
 			likes.each(function () {

Tags: invis89, js, livejournal, vvasin
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments