Inefficiently keeps adding on-resize listeners
-
I’s pretty cool there is a ‘post-load’ and ‘wcs-toggled’ event you can call to re-set-up galleries from ajax/infinite scroll, but I noticed a potentially big performance problem:
Add console.log(‘resizerun’); to the start of runMasonry function, and note that it runs some number of times.
Now run jQuery(document.body).trigger(‘post-load’) and then jQuery(window).trigger(‘resize’)
Notice the number of console.logs printed out doubles because it keeps adding resize events to run. Ideally this would use .off( ‘resize’, myfunction), then .on( ‘resize’, myfunction ) to not add so many listeners.
As it is, depending on how many times that event is called, there could be hundreds or thousands of the same routine running on resize event.
- The topic ‘Inefficiently keeps adding on-resize listeners’ is closed to new replies.