Loading...
Loading...
Compare original and translation side by side
undefinedundefined
Or open Chrome DevTools → Lighthouse tab → Analyse page load.
**Target scores:**
| Category | Target |
|---|---|
| Performance | ≥ 90 |
| Accessibility | 100 |
| Best Practices | ≥ 95 |
| SEO | ≥ 95 |
---
或者打开Chrome开发者工具 → Lighthouse标签页 → 分析页面加载。
**目标评分:**
| 分类 | 目标值 |
|---|---|
| 性能 | ≥ 90 |
| 可访问性 | 100 |
| 最佳实践 | ≥ 95 |
| SEO | ≥ 95 |
---| Cause | Fix |
|---|---|
| Unoptimised hero image | Use WebP/AVIF, correct size, |
| Image not preloaded | |
| Render-blocking CSS/JS | Defer non-critical JS, inline critical CSS |
| Slow server response | CDN, caching headers, edge delivery |
| Web font blocking render | |
<!-- Preload LCP image -->
<link rel="preload" as="image" href="hero.webp" fetchpriority="high">
<!-- LCP image: no lazy loading -->
<img src="hero.webp" alt="..." fetchpriority="high" width="1200" height="600">loading="lazy"| 问题原因 | 修复方法 |
|---|---|
| 首屏图片未优化 | 使用WebP/AVIF格式、设置正确尺寸、添加 |
| 图片未预加载 | 添加 |
| CSS/JS阻塞渲染 | 延迟非关键JS加载、内联关键CSS |
| 服务器响应缓慢 | 使用CDN、配置缓存头、边缘分发 |
| Web字体阻塞渲染 | 设置 |
<!-- 预加载LCP图片 -->
<link rel="preload" as="image" href="hero.webp" fetchpriority="high">
<!-- LCP图片:禁止懒加载 -->
<img src="hero.webp" alt="..." fetchpriority="high" width="1200" height="600">loading="lazy"| Cause | Fix |
|---|---|
| Images without width/height | Always set |
| Web font swap | Use |
| Dynamic content above fold | Reserve space with |
| Late-loading ads or embeds | Reserve fixed dimensions for ad slots |
| Animations that shift layout | Animate |
<!-- Always include dimensions -->
<img src="product.jpg" width="400" height="300" alt="...">/* Reserve space for dynamic content */
.ad-slot { min-height: 250px; }
/* Animate transform, not layout properties */
.slide-in { transform: translateY(0); transition: transform 300ms; }| 问题原因 | 修复方法 |
|---|---|
| 图片未设置宽高 | 始终为 |
| Web字体切换 | 使用 |
| 首屏上方的动态内容 | 为容器设置 |
| 延迟加载的广告或嵌入内容 | 为广告位预留固定尺寸 |
| 导致布局偏移的动画 | 仅对 |
<!-- 始终包含尺寸属性 -->
<img src="product.jpg" width="400" height="300" alt="...">/* 为动态内容预留空间 */
.ad-slot { min-height: 250px; }
/* 对transform设置动画,而非布局属性 */
.slide-in { transform: translateY(0); transition: transform 300ms; }| Cause | Fix |
|---|---|
| Heavy JS on main thread | Break into smaller tasks, use |
| Large event handlers | Debounce/throttle scroll and resize handlers |
| Synchronous DOM updates | Batch DOM writes with |
| Third-party scripts blocking | Load third-party scripts with |
| React re-renders | Memoize with |
| 问题原因 | 修复方法 |
|---|---|
| 主线程JS负载过重 | 拆分为更小任务、使用 |
| 大型事件处理器 | 对滚动和 resize 事件处理器进行防抖/节流 |
| 同步DOM更新 | 使用 |
| 第三方脚本阻塞 | 使用 |
| React重复渲染 | 使用 |
<!-- Modern formats with fallback -->
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" width="800" height="600" alt="..." loading="lazy">
</picture>
<!-- Responsive images -->
<img
srcset="image-400.webp 400w, image-800.webp 800w, image-1200.webp 1200w"
sizes="(max-width: 600px) 100vw, 50vw"
src="image-800.webp"
alt="..."
width="800"
height="600"
loading="lazy"
>widthheightloading="lazy"<!-- 现代格式带降级方案 -->
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" width="800" height="600" alt="..." loading="lazy">
</picture>
<!-- 响应式图片 -->
<img
srcset="image-400.webp 400w, image-800.webp 800w, image-1200.webp 1200w"
sizes="(max-width: 600px) 100vw, 50vw"
src="image-800.webp"
alt="..."
width="800"
height="600"
loading="lazy"
>widthheightloading="lazy"<!-- Preconnect to font origin -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Preload critical font file -->
<link rel="preload" href="/fonts/brand.woff2" as="font" type="font/woff2" crossorigin>@font-face {
font-family: 'Brand';
src: url('/fonts/brand.woff2') format('woff2');
font-display: swap; /* show fallback immediately, swap when loaded */
/* font-display: optional; — never swap, use fallback if not cached */
}font-display: swapfont-display: optional<!-- 预连接到字体源 -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- 预加载关键字体文件 -->
<link rel="preload" href="/fonts/brand.woff2" as="font" type="font/woff2" crossorigin>@font-face {
font-family: 'Brand';
src: url('/fonts/brand.woff2') format('woff2');
font-display: swap; /* 立即显示 fallback 字体,加载完成后替换 */
/* font-display: optional; — 绝不替换,仅在缓存时使用自定义字体 */
}font-display: swapfont-display: optional<!-- Defer non-critical scripts -->
<script src="analytics.js" defer></script>
<script src="chat-widget.js" async></script>
<!-- Module scripts are deferred by default -->
<script type="module" src="app.js"></script>deferasync<script><head><!-- 延迟非关键脚本加载 -->
<script src="analytics.js" defer></script>
<script src="chat-widget.js" async></script>
<!-- 模块脚本默认延迟加载 -->
<script type="module" src="app.js"></script>deferasync<head><script>undefinedundefined
```yaml
```yaml
---
---loading="lazy"widthheightloading="lazy"font-display: swapoptionaldeferasyncloading="lazy"widthheightloading="lazy"font-display: swapoptionaldeferasync