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
The text was updated successfully, but these errors were encountered:
认领 @barretlee
Sorry, something went wrong.
简单来说,懒执行(Lazy Execution)就是对特定功能逻辑的初始化进行全部或部分的延迟,直到满足某一触发条件,再进行剩余部分的初始化。
懒执行的主要作用在于性能优化,再确切一点应该是首屏优化。在首屏中存在某些模块或者功能逻辑,首屏加载过程中并不会被立即使用或者使用频率非常低。为了使首屏加载性能达到最优,此时对上述这种低需或者低频的功能逻辑可以延迟进行初始化,也就是所谓的懒执行。
场景距离的含义我不是很明白,还是得请小胡子哥补充
某一业务功能如果被设置了懒执行,则需要满足特定条件后该功能才会被初始化(唤醒)。
因此,从剩余逻辑被初始化的触发(唤醒)方式上来看,懒执行的通用方案可以大致上分为两个思路:自动唤醒和手动唤醒
自动唤醒
setInterval()
monitor()
clearInterval
从上述分析来看,自动唤醒的方案需要轮询逻辑作为支撑,本身占用一定资源。因此自动唤醒应当被用于大型逻辑模块的懒执行方案中,否则有可能在性能上会得不偿失。
手动唤醒
手动唤醒主要应用于页面的交互场景下,也就是通过监听用户在页面内的 click 、 hover 或 scroll 等基本交互行为来触发唤醒动作。
click
hover
scroll
手动唤醒无需设置唤醒条件,也就不需要定义轮询函数来监听,完全由用户手动控制逻辑的触发,更加节省资源。因此中小型模块的懒执行方案可以选用手动唤醒方案。
No branches or pull requests
认领人须知
The text was updated successfully, but these errors were encountered: