LCP元素加载太慢,怎么优化首屏大图?
我在用 Lighthouse 测速时发现 LCP(最大内容绘制)得分很低,主要卡在首页那张 hero banner 图上。这张图是用 <img> 标签直接引入的,尺寸大概 1920×800,已经压缩到 300KB 左右了,但还是经常在 4s 后才显示。
我试过加 loading="eager" 和 fetchpriority="high",也用了 CDN,但效果不明显。是不是应该换成背景图?或者用 WebP 格式?下面是我现在的写法:
<img
src="/images/hero-banner.jpg"
alt="Hero Banner"
loading="eager"
fetchpriority="high"
style="width: 100%; height: auto;"
/>
暂无解答