← 返回 Skills 市场
chenxiaoyu0124-web

前端性能审计清单

作者 chenxiaoyu0124-web · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
109
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install frontend-perf-audit
功能描述
提供网页性能诊断流程和优化建议,涵盖Core Web Vitals、资源加载、代码分割、图片懒加载与缓存策略。
使用说明 (SKILL.md)

前端性能审计清单

Core Web Vitals 目标

指标 含义 目标
LCP 最大内容绘制 \x3C 2.5s > 4s
FID/INP 交互延迟 \x3C 100ms > 300ms
CLS 布局偏移 \x3C 0.1 > 0.25

诊断流程

Step 1: Lighthouse 审计

# Chrome DevTools → Lighthouse → 生成报告
# 或命令行
npx lighthouse https://your-site.com --output html --output-path ./report.html

重点关注:

  • Performance 分数(目标 > 90)
  • Opportunities(优化建议,按影响排序)
  • Diagnostics(诊断信息)

Step 2: Coverage 分析

F12 → Coverage → 点击录制 → 操作页面 → 查看未使用代码

// vite.config.ts — 代码分割
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          'vendor': ['vue', 'vue-router', 'pinia'],
          'ui': ['ant-design-vue'],
          'chart': ['@antv/s2', 'three'],
        },
      },
    },
  },
})

Step 3: Network 瀑布图

F12 → Network → 过滤 Doc/JS/CSS/Img

检查:

  • JS Bundle 总大小(目标 \x3C 500KB gzipped)
  • 是否有阻塞渲染的资源
  • 是否利用了缓存(304/200 from cache)

优化策略

LCP 优化(最大内容绘制 \x3C 2.5s)

// 1. 关键 CSS 内联
// vite-plugin-critical 提取首屏 CSS 内联到 HTML

// 2. 图片懒加载
\x3Cimg v-lazy="imageUrl" alt="description" />
// 或原生
\x3Cimg loading="lazy" src="image.jpg" alt="description" />

// 3. 预加载关键资源
\x3Clink rel="preload" href="/fonts/main.woff2" as="font" crossorigin>
\x3Clink rel="preload" href="/js/chunk-vendor.js" as="script">

// 4. 骨架屏
\x3CSuspense>
  \x3Ctemplate #default>\x3CMainContent />\x3C/template>
  \x3Ctemplate #fallback>\x3CSkeletonScreen />\x3C/template>
\x3C/Suspense>

// 5. 字体优化
\x3Clink rel="preconnect" href="https://fonts.googleapis.com">
\x3Clink rel="dns-prefetch" href="https://fonts.gstatic.com" crossorigin>

CLS 优化(布局偏移 \x3C 0.1)

/* 1. 图片/视频容器预留空间 */
.media-container {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #f5f5f5;
}

/* 2. 字体回退策略 */
body {
  font-family: -apple-system, 'PingFang SC', sans-serif;
}

/* 3. 动态内容区域预留最小高度 */
.dynamic-content {
  min-height: 200px;
}

Bundle 优化

// vite.config.ts
export default defineConfig({
  build: {
    target: 'es2020',
    minify: 'terser',
    terserOptions: {
      compress: {
        drop_console: true,     // 生产环境去掉 console
        drop_debugger: true,
      },
    },
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return 'vendor'
          }
          if (id.includes('ant-design')) {
            return 'ui'
          }
        },
      },
    },
    chunkSizeWarningLimit: 500,
  },
})

缓存策略

// vite.config.ts
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        // 文件名带 hash,利于长期缓存
        entryFileNames: 'assets/[name].[hash].js',
        chunkFileNames: 'assets/[name].[hash].js',
        assetFileNames: 'assets/[name].[hash].[ext]',
      },
    },
  },
})

// nginx 配置
// assets/ — Cache-Control: public, max-age=31536000, immutable
// index.html — Cache-Control: no-cache

持续监控

// 在应用中埋点
if ('PerformanceObserver' in window) {
  const observer = new PerformanceObserver((list) => {
    for (const entry of list.getEntries()) {
      console.log(entry.name, entry.startTime, entry.duration)
    }
  })
  observer.observe({ type: 'largest-contentful-paint', buffered: true })
  observer.observe({ type: 'layout-shift', buffered: true })
  observer.observe({ type: 'first-input', buffered: true })
}

优化优先级

  1. 消除渲染阻塞 — 内联关键 CSS、async/defer JS
  2. 图片优化 — WebP/AVIF、懒加载、响应式图片
  3. 代码分割 — 路由懒加载、vendor 分离
  4. 缓存策略 — hash 文件名 + 长期缓存
  5. 字体优化 — preconnect + font-display: swap
  6. 服务端 — gzip/brotli、CDN、HTTP/2

一句话总结

先消除渲染阻塞,再优化资源加载,最后做代码分割和缓存 — 按这个顺序效果最大。

安全使用建议
This is a readable checklist and code-snippet collection for frontend performance auditing — it appears coherent and safe. Before using: (1) review and test any config/code changes in a staging environment (don’t paste snippets blindly into production); (2) running suggested commands like `npx lighthouse` will download and run an npm package at runtime — only run those on a trusted machine and network; (3) note a small metadata mismatch (pack metadata version differs from registry version) — likely benign but worth noticing; (4) because this skill is instruction-only, it won’t automatically execute code, but if you invoke suggested commands they will run on your system, so exercise usual caution.
功能分析
Type: OpenClaw Skill Name: frontend-perf-audit Version: 1.1.0 The skill bundle is a legitimate educational resource for frontend performance auditing. It contains standard diagnostic procedures using Lighthouse and provides best-practice code snippets for Vite configuration, CSS optimization, and performance monitoring in SKILL.md. There are no signs of data exfiltration, malicious execution, or prompt injection.
能力标签
crypto
能力评估
Purpose & Capability
The name/description (frontend performance audit) matches the SKILL.md: Lighthouse, DevTools workflows, vite/nginx snippets, and PerformanceObserver usage are appropriate and expected for this purpose. No unrelated binaries, credentials, or config paths are requested.
Instruction Scope
Instructions are scoped to performance diagnosis and remediation steps (Lighthouse, Coverage, Network, config/code examples). They do not instruct reading system files, secrets, or sending data to unexpected external endpoints. The only network action suggested is running npx lighthouse or loading resources from CDNs, which is consistent with the topic.
Install Mechanism
No install spec or code files are included (instruction-only). This is low-risk. Note: SKILL.md suggests using npx (which fetches an npm package at runtime) but that is a normal, user-invoked diagnostic action rather than an automatic install by the skill.
Credentials
The skill requests no environment variables, credentials, or config paths. That is proportionate to a documentation/checklist skill.
Persistence & Privilege
always is false and the skill does not request persistent system presence or modify other skills. Agent autonomous invocation is allowed (platform default) but is not combined here with other red flags.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install frontend-perf-audit
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /frontend-perf-audit 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
新增定价,内容不变
v1.0.0
初始发布:Core Web Vitals+Bundle优化+缓存策略
元数据
Slug frontend-perf-audit
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

前端性能审计清单 是什么?

提供网页性能诊断流程和优化建议,涵盖Core Web Vitals、资源加载、代码分割、图片懒加载与缓存策略。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 109 次。

如何安装 前端性能审计清单?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install frontend-perf-audit」即可一键安装,无需额外配置。

前端性能审计清单 是免费的吗?

是的,前端性能审计清单 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

前端性能审计清单 支持哪些平台?

前端性能审计清单 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 前端性能审计清单?

由 chenxiaoyu0124-web(@chenxiaoyu0124-web)开发并维护,当前版本 v1.1.0。

💬 留言讨论