We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throtting:在一段时间内,对调用函数的最大次数进行限制,比如:在100ms内最多执行一次该函数。
举个例子,如果你的函数会在10s内执行1000次,比如触发scroll事件,这时候性能开销就比较大,我们可以使用throttle进行控制,让函数每100ms执行一次,这样,10s内最大执行的次数为100次,有效减少了性能开销。
scroll
debouncing:经过一段时间以后才执行相应的函数。并且该函数只执行一次,比如:100ms以后才执行和这个函数。
举个例子:如果你的函数会在10s内执行1000次,比如触发scroll事件,当我们加上debounce的特效后,设置经过100ms后执行,Duang的一下,函数不会再这10s内执行了,相反,它会在事件结束后开始算起,经过100ms执行,也就是说在10.1s执行的该函数。
原文:http://youthol.top/2016/05/11/javascript-throttle-and-debounce/
扩展:http://hackll.com/2015/11/19/debounce-and-throttle/
The text was updated successfully, but these errors were encountered:
No branches or pull requests
throttling 与 debouncing 都可以对执行的函数进行速率限制。
throtting:在一段时间内,对调用函数的最大次数进行限制,比如:在100ms内最多执行一次该函数。
举个例子,如果你的函数会在10s内执行1000次,比如触发

scroll
事件,这时候性能开销就比较大,我们可以使用throttle进行控制,让函数每100ms执行一次,这样,10s内最大执行的次数为100次,有效减少了性能开销。debouncing:经过一段时间以后才执行相应的函数。并且该函数只执行一次,比如:100ms以后才执行和这个函数。
举个例子:如果你的函数会在10s内执行1000次,比如触发

scroll
事件,当我们加上debounce的特效后,设置经过100ms后执行,Duang的一下,函数不会再这10s内执行了,相反,它会在事件结束后开始算起,经过100ms执行,也就是说在10.1s执行的该函数。原文:http://youthol.top/2016/05/11/javascript-throttle-and-debounce/
扩展:http://hackll.com/2015/11/19/debounce-and-throttle/
The text was updated successfully, but these errors were encountered: