fix: change LCP image from png to webp #142
Open
+4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Key Changes
This PR focuses on optimizing performance metrics, specifically First Contentful Paint (FCP) and Largest Contentful Paint (LCP), through various improvements. All of these analyses were analyzed by lighthouse in Chrome.
Initial Performance Issues
The current LCP file is the following image. It is ff-symbol-gradient.png
When using the current png file as it is
The site currently experiences suboptimal performance: FCP is around 2.6 seconds, it exceeds the ideal time of 1.8 seconds LCP is around 6 seconds, significantly higher than the recommended 2.5 secondsImplemented Optimizations
Converted ff-symbol-gradient.png to WebP format
Tested different quality settings (80%, 60%, 40%) to find optimal balance
Results showed improved performance metrics while maintaining visual quality
Even if the quality is only 80 percent, the performance benefits are sufficient.
Changing png to webp only reduces LCP by half. However, this does not solve the underlying problem.
Current problematic implementation:
If you comment out these two parts, the performance changes as follows
However, this approach has many issues as it simply removes the code without considering the side effects in the font usage.
A better method would be to bundle the CSS files within the project instead of loading them through the network.
Copy the static CSS that was previously loaded through the two links and define it internally as follows:
While it would work fine to save and use the downloaded CSS files in the public/fonts folder, this isn't included in this PR as it could raise legal issues. If it's acceptable, I'll add this in an additional commit. 🙂
After applying this change, we can observe the following performance metrics while maintaining the use of existing fonts..!
How about introducing the Slash library developed by Toss?
https://www.slash.page/ko/libraries/react/async-stylesheet/src/index.i18n
🖼️ Before and After Comparison
中文版
此PR主要通过各种改进来优化性能指标,特别是First Contentful Paint (FCP)和Largest Contentful Paint (LCP)。所有这些分析都是通过Chrome中的lighthouse进行的。
初始性能问题
当前的LCP文件是以下图片:ff-symbol-gradient.png
使用当前png文件时的情况
网站目前性能表现不佳: FCP约为2.6秒,超过了理想时间1.8秒 LCP约为6秒,远高于建议的2.5秒已实施的优化
将ff-symbol-gradient.png转换为WebP格式
测试了不同的质量设置(80%、60%、40%)以找到最佳平衡点
结果显示在保持视觉质量的同时改善了性能指标
即使质量只有80%,性能提升也已经足够。
将png更改为webp只能将LCP减少一半。然而,这并不能解决根本问题。
当前存在问题的实现:
如果注释掉这两部分,性能变化如下:
然而,这种方法存在许多问题,因为它只是简单地删除代码而没有考虑字体使用方面的副作用。
更好的方法是在项目内部打包CSS文件,而不是通过网络加载。
将之前通过两个链接加载的静态CSS复制下来,按照以下方式在内部定义:
虽然将下载的CSS文件保存在public/fonts文件夹中并使用是可行的,但由于可能涉及法律问题,这部分未包含在本PR中。如果可以接受的话,我会在后续提交中添加这部分内容。🙂
应用此更改后,我们可以在保持现有字体使用的同时观察到以下性能指标..!
考虑引入Toss开发的Slash库如何?
https://www.slash.page/ko/libraries/react/async-stylesheet/src/index.i18n
🖼️ Before and After Comparison