| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| }, minimumInterval - sinceLastTime); | ||
| // Inside minimum interval, create timer if needed. | ||
| if (typeof deferTimer === 'undefined') { | ||
| deferTimer = setTimeout(timerExpired, minimumInterval - sinceLastTime); |
There was a problem hiding this comment.
can do a single line
deferTimer = deferTimer || setTimeout(timerExpired, minimumInterval - sinceLastTime);
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
…throttleLeadingAndTrailing
|
Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description:
The implementation of throttleLeadingAndTrailing was very inefficient when many updates took place in short succession. Virtually all invocations would result in clearing a timer, allocating a new function and creating a new timer. This impacted both the performance and memory usage of setAttribute.
Using the performance/set-attribute and performance/animation-set-attribute benchmarks showed a clear performance benefit (when congested) cutting the duration in half (~9.16µs/op -> ~4.04µs/op) and reduced memory consumption:

Instead of allocating a new function for each timer, one is created in advance. In case calls take place within the minimumInterval only one timer is created and re-used until it expires ensuring at most one timer per interval (if needed).
Changes proposed: