Skip to content
New issue

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

【文章错误】面试官:SPA首屏加载速度慢的怎么解决? #430

Open
ruofee opened this issue Apr 12, 2024 · 0 comments
Open

Comments

@ruofee
Copy link

ruofee commented Apr 12, 2024

首屏时间(First Contentful Paint),指的是浏览器从响应用户输入网址地址,到首屏内容渲染完成的时间,此时整个网页不一定要全部渲染完成,但需要展示当前视窗需要的内容

事实上,FCP 并不是首屏内容渲染完成的时间,而是内容第一次发生渲染的时间,MDN 中的解释:

首次内容绘制(FCP)是指浏览器渲染 DOM 中的第一部分内容,向用户提供页面正在加载的第一次反馈的时间。在首次内容绘制完成时,问题“它正在发生吗?”的答案为“是”。

另外一处错误,在 "开启GZip压缩" 部分,提到客户端可以通过配置 compression-webpack-plugin 产出 gzip 压缩格式的产物,并且服务器(express)需要使用 compression 模块才能将 gzip 的产物返回,实际上这是错的,compression 能够在返回资源的时候进行压缩,但不能根据你的请求返回服务器中已经存在的 gzip 格式的产物,如果你想实现对应的功能,你应该选择:https://github.com/tkoenig89/express-static-gzip

纸上得来终觉浅,绝知此事要躬行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant