azl397985856 / fe-interview

宇宙最强的前端面试指南 (https://lucifer.ren/fe-interview)
Apache License 2.0
2.83k stars 260 forks source link

【每日一题】- 2020-04-20 - 浏览器tab转圈圈是怎么做到的? #115

Closed azl397985856 closed 4 years ago

azl397985856 commented 4 years ago

image

如上,浏览器会在页面加载的过程中转圈,加载完成之后就停止了。 那么具体什么时候开始转,什么时候停止呢?这个功能是怎么实现的(内部原理是怎么样的)?

扩展:

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

azl397985856 commented 4 years ago

监听资源加载的事件,当首屏资源全部加载完成就将loading去掉即可。

如果你是做内核开发,可以直接监听静态资源的声明周期,如果你是web 前端,可以监听 onload 事件。

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.