Front-end knowledge sharing--anti-shake and throttling

One: Concept

Stabilization and throttling are both ways to optimize performance

Anti-shake: continuous triggering will not be executed, and it will be executed if it is not triggered for a period of time

Throttling: continuous triggering is also executed, but the frequency of execution becomes lower

The translation is: anti-shake is a period of time after the event is triggered (which can be understood as a delay) and then executes the callback

The second throttling is to repeat the trigger within the unit time of the event trigger and only execute it once. This is the difference between the two.

Two: application scenarios

Anti-shake: request interface according to the input content, click event for frequent triggering, input search box, etc.

Throttling: page size scaling, pull-down refresh, etc.

おすすめ

転載: blog.csdn.net/weixin_71171795/article/details/129133188