har-performance-analyzer

HAR performance analyzer: analyze browser-exported HAR (HTTP Archive) files to diagnose page performance issues. Identifies slow requests, large resources, render-blocking resources (JS/CSS), caching issues, third-party impact, and DNS/SSL/TCP overhead, and provides actionable optimization suggestions. Triggered when the user mentions HAR files, page performance, or supplies a .har file.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "har-performance-analyzer" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c0da0100b080d5abc4cadf279cb2e1dcfbddc6a78c8236c95e2a32b540e5584e. Verify the upstream source and version against https://skillhub.cn/skills/user_b30f8db8/har-performance-analyzer before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

HAR performance analyzer: analyze browser-exported HAR (HTTP Archive) files to diagnose page performance issues. Identifies slow requests, large resources, render-blocking resources (JS/CSS), caching issues, third-party impact, and DNS/SSL/TCP overhead, and provides actionable optimization suggestions. Triggered when the user mentions HAR files, page performance, or supplies a .har file.

0 Downloads

Introduction source: third_party · user_b30f8db8 · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: har-performance-analyzer
description: |
  当使用浏览器导出的 HAR(HTTP Archive)文件分析页面性能时,应使用此技能。
  当用户提及 HAR 文件、浏览器性能分析、页面加载瓶颈、
  前端性能优化,或提供 .har 文件用于分析时触发。
  支持识别慢请求、大资源、渲染阻塞资源(JS/CSS)、
  缓存问题、第三方影响、DNS/SSL/TCP 开销,并提供可操作的优化建议。

HAR 性能分析器

概述

分析浏览器导出的 HAR 文件,识别页面加载性能瓶颈,并生成可操作的优化建议。该技能使用 Python 分析脚本(scripts/analyze_har.py)解析 HAR JSON 结构,生成全面的性能报告。

理解 HAR 文件

HAR(HTTP Archive)文件是一个 JSON 格式的日志,记录了网页发出的所有网络请求,可从浏览器 DevTools 导出。它包含:

  • 时序数据:每个请求的 DNS 查询、TCP 连接、SSL 握手、TTFB(首字节时间)、下载时间
  • 请求/响应详情:URL、头部信息、状态码、响应体大小、MIME 类型
  • 发起者信息:触发每个请求的来源(解析器、脚本、XHR 等)
  • 页面级指标:onLoad、DOMContentLoaded 时间戳

使用 HAR 分析器

第 1 步:获取 HAR 文件

指导用户从浏览器导出 HAR 文件:

  1. 打开 Chrome/Firefox/Edge DevTools(按 F12)
  2. 进入 Network(网络) 标签页
  3. 勾选 "Preserve log(保留日志)" 和 "Disable cache(禁用缓存)"(可选,但建议用于冷加载分析)
  4. 刷新页面
  5. 在请求列表中右键 → "Save all as HAR with content(另存为包含内容的 HAR 文件)"
  6. 提供保存的 .har 文件路径以供分析

第 2 步:运行分析脚本

执行内置的 Python 脚本生成性能报告:

# 生成 HTML 报告(推荐,可读性最佳)
python3 scripts/analyze_har.py <har文件路径> --html report.html

# 终端文本输出
python3 scripts/analyze_har.py <har文件路径> [--top 20] [--domain example.com]

# 机器可读的 JSON 格式
python3 scripts/analyze_har.py <har文件路径> --json > report.json

选项:

选项 说明
--top N Top 列表显示的条目数量(默认:20)
--domain DOMAIN 指定主域名(未指定则自动检测)
--json 以机器可读的 JSON 格式输出
--html OUTPUT.html 导出为自包含、排版精美的 HTML 报告

第 3 步:查看 HTML 报告

使用 --html 时,脚本会生成一个自包含的 HTML 文件,可在任意浏览器中打开。HTML 报告包含以下特性:

  • 摘要卡片 — 总请求数、传输大小、页面加载指标,带颜色编码严重级别(绿色/黄色/红色)
  • 资源类型分布 — JS、CSS、图片、字体、XHR 等的颜色编码卡片
  • 时序瀑布图 — 可视化条形图,展示时间消耗分布(DNS、SSL、TTFB、下载)
  • 响应时间分布 — 带动画效果的柱状图直方图
  • 可排序表格 — 最慢请求、最大资源、缓存问题
  • 域名分析 — 自有域名 vs 第三方域名拆解,带标签标注
  • 优化建议 — 带严重等级指示的优先级操作项
  • 无外部依赖 — 所有 CSS/JS 均为内联,可离线使用

第 4 步:解读结果

报告涵盖以下部分:

  1. 总体概况 — 总请求数、传输大小、主域名
  2. 页面加载时间 — DOMContentLoaded、onLoad 指标
  3. HTTP 状态码分布 — 错误检测(4xx、5xx)
  4. 响应时间分布 — 分布直方图
  5. 资源类型分布 — JS/CSS/图片/字体/XHR 的数量和大小
  6. 域名分布 — 按域名分组的请求、第三方标注
  7. 请求时序分解 — 时间消耗分布:DNS、SSL、TTFB、下载等
  8. 最慢的请求 — Top N 最慢请求,优化优先级最高
  9. 最大的资源 — Top N 最大资源,压缩/优化候选
  10. 渲染阻塞资源 — 阻塞解析器的 JS/CSS,延迟首次绘制
  11. 缓存策略问题 — 缺少正确缓存头的资源
  12. 连接开销 — DNS/SSL/TCP 建立时间过高的请求
  13. 第三方资源影响 — 外部域名请求汇总
  14. 优化建议 — 具体、按优先级排序的优化操作

第 5 步:提供优化建议

根据分析结果,提供具体且按优先级排序的优化建议。常见优化策略包括:

瓶颈 建议
TTFB 慢 升级服务器、使用 CDN、优化后端处理
DNS/SSL/TCP 开销高 减少域名数量、使用 dns-prefetch / preconnect、启用 HTTP/2
渲染阻塞 JS/CSS 延迟非关键 JS(async / defer)、内联关键 CSS
JS 包体积过大 Tree shaking、代码分割、动态 import()
图片过大 使用 WebP/AVIF、懒加载、响应式图片(srcset)
缺少缓存头 为静态资源设置 Cache-Control: max-age=31536000
请求数过多 打包资源、使用 HTTP/2 多路复用、雪碧图
第三方脚本臃肿 审计并移除未使用的第三方脚本、使用门面模式

使用 JSON 输出进一步处理

指定 --json 时,脚本输出结构化数据,便于程序化处理或与其他工具集成:

python3 scripts/analyze_har.py page.har --json > report.json

关键性能指标参考

讨论结果时,参考以下常见性能阈值:

  • TTFB(首字节时间):< 200ms(良好),200-500ms(需改进),> 500ms(较差)
  • DOMContentLoaded:< 1s(良好),1-3s(可接受),> 3s(需优化)
  • onLoad:< 2s(良好),2-5s(可接受),> 5s(较差)
  • 单个请求:< 100ms(良好),100-500ms(可接受),> 1s(需排查)
  • 页面总大小:< 2MB(移动端良好),2-5MB(可接受),> 5MB(需精简)

边界情况

  • 大型 HAR 文件(>100MB):脚本在内存中处理所有条目。对于非常大的文件,建议在 DevTools 中导出前先进行过滤(例如,仅导出特定的页面加载记录)
  • 缺少 pageTimings:某些 HAR 导出缺少页面级时序数据。脚本会回退到条目级分析
  • 编码过的响应体:HAR 文件可能在 content.text 中包含 base64 编码的响应体。默认情况下脚本不会解码,而是使用响应头中的 bodySize 进行大小分析
  • 多个页面加载:如果 HAR 包含多个页面加载记录,脚本会将所有条目一起分析。建议只导出相关的单个页面加载,以便进行聚焦分析

Current listing version

1.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 HAR 文件分析能力,解决前端性能优化的明确痛点
  • 功能完整闭环,从导出指导到分析再到优化建议
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖 HAR 文件、性能分析、.har 文件等多种变体
  • 边界清晰,不易与其他 Skill 重叠
Structure and Standards90/100

Highlights

  • 文档结构完整,包含概述、使用步骤、示例、选项说明、边界情况
  • Phase 清晰,有端到端示例,frontmatter 完整
Execution Reliability60/100

Areas to improve

  • 引用文件缺失 Reported severity: Major

    SKILL.md 中引用了 scripts/analyze_har.py 脚本,但该文件未包含在传入的 ZIP 包中

    Recommendation: 请确保 scripts/analyze_har.py 文件随 Skill 一起提交,否则用户无法执行核心分析功能

Evidence Verifiability (mean of the first four)83/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.