performance-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Performance Audit

性能审计

Find what makes a site slow to load and fix it by template: render-blocking resources, the largest image, oversized scripts and images, missing compression and caching, slow server response, font loading and layout shift.
squirrelscan's performance rules read the page's markup, headers and fetched resources. They flag the causes behind Core Web Vitals; they are not real-user measurements. Google's thresholds, judged at the 75th percentile of field data, are: Largest Contentful Paint 2.5 s or less, Interaction to Next Paint 200 ms or less, Cumulative Layout Shift 0.1 or less (https://web.dev/articles/vitals). To confirm a fix moved real users, the user needs field data (the Chrome UX Report or PageSpeed Insights).
找出导致网站加载缓慢的原因,并按模板进行修复:阻塞渲染的资源、最大图片、超大脚本和图片、缺失的压缩与缓存、服务器响应缓慢、字体加载和布局偏移。
squirrelscan 的性能规则会读取页面的标记、响应头和已获取资源。它们会指出导致 Core Web Vitals 指标异常的根本原因;这些结果并非真实用户测量数据。Google 的阈值依据现场数据(field data)的第 75 百分位判定:Largest Contentful Paint 不超过 2.5 s,Interaction to Next Paint 不超过 200 ms,Cumulative Layout Shift 不超过 0.1(https://web.dev/articles/vitals)。要确认某项修复是否改善了真实用户体验,用户需要现场数据(Chrome UX Report 或 PageSpeed Insights)。

Before the first audit

首次审计前

Run
squirrel --version
. If it fails, install the CLI from squirrelscan.com/download (the
squirrelscan
skill has
references/install.md
). Then run
squirrel auth status
:
  • Signed out, or
    --offline
    : the audit runs on this machine, is free, and nothing is published.
  • Signed in: the audit is billed in credits (50 plus 2 per audited page, plus 1 per distinct external link the cloud verifies), adds the site to the user's dashboard, can turn on recurring audits and publishes an unlisted report. Tell the user the cost (
    squirrel credits
    ) and get a yes. Offer
    --offline
    or
    --no-publish
    . For a site the user does not own, add
    --ephemeral
    : nothing is added to the dashboard, scheduled or published.
Every flag below is checked against the squirrel CLI docs (https://docs.squirrelscan.com/cli/audit). Rule docs:
https://docs.squirrelscan.com/rules/{category}/{rule_id}
.
运行
squirrel --version
。如果失败,请从 squirrelscan.com/download 安装 CLI(
squirrelscan
skill 中包含
references/install.md
)。然后运行
squirrel auth status
:
  • **未登录,或使用
    --offline
    :**审计将在本机运行,免费,且不会发布任何内容。
  • **已登录:**审计将消耗 credits(基础费用为 50 credits,每个受审计页面另加 2 credits,云端验证的每个不同外部链接另加 1 credit),将站点加入用户的面板,可启用定期审计,并发布一份非公开报告。请告知用户费用(
    squirrel credits
    ),并获得其明确同意。可以提供
    --offline
    或
    --no-publish
    。对于用户并不拥有的网站,添加
    --ephemeral
    :不会将站点加入面板、安排定期审计或发布报告。

Run it

运行

bash
squirrel audit https://example.com --level surface \
  --rule-include perf,images --format json -o perf.json
  • Audit the live site: only there do compression, caching, HTTP version and server response times reflect production. A local dev server shows development bundles.
  • surface
    covers one page per template, which is what performance work needs. Add
    --level full
    for sign-off.
  • Read the
    perf
    category score:
    squirrel report <audit-id> --group performance --format llm
    .
bash
squirrel audit https://example.com --level surface \
  --rule-include perf,images --format json -o perf.json
  • 审计线上站点:只有针对线上站点进行审计,压缩、缓存、HTTP 版本和服务器响应时间才会反映生产环境情况。本地开发服务器显示的是开发构建产物。
  • surface
    级别会覆盖每个模板中的一个页面,这正是性能工作所需的范围。签核时添加
    --level full
    。
  • 读取
    perf
    类别得分:
    squirrel report <audit-id> --group performance --format llm
    。

Fix order (biggest effect first)

修复顺序(先处理影响最大的)

  1. Loading the main content:
    perf/lcp-hints
    ,
    perf/lcp-fetchpriority
    ,
    perf/lazy-above-fold
    ,
    perf/render-blocking
    ,
    perf/critical-request-chains
    ,
    perf/preconnect
    ,
    perf/ttfb
    .
  2. Bytes:
    perf/total-byte-weight
    ,
    perf/js-file-size
    ,
    perf/css-file-size
    ,
    perf/duplicate-js
    ,
    perf/legacy-js
    ,
    perf/unminified-js
    ,
    perf/unminified-css
    ,
    perf/content-in-js-bundle
    ,
    perf/framework-data-payload
    ,
    images/image-file-size
    ,
    images/modern-format
    ,
    images/responsive-size
    .
  3. Delivery:
    perf/compression
    ,
    perf/asset-compression
    ,
    perf/cache-headers
    ,
    perf/bad-caching
    ,
    perf/http2
    .
  4. Stability and responsiveness:
    perf/cls-hints
    ,
    images/dimensions
    ,
    perf/font-loading
    ,
    perf/font-delivery
    ,
    perf/inp-hints
    ,
    perf/dom-size
    .
  5. Hygiene:
    perf/source-maps
    ,
    perf/js-libraries
    ,
    perf/js-redirects
    ,
    images/lazy-loading
    ,
    images/offscreen-lazy
    .
Do not lazy-load the main (largest) image: the audit flags that, and it is a common regression. Get each rule's exact fix from its docs page.
  1. 加载主要内容:
    perf/lcp-hints
    、
    perf/lcp-fetchpriority
    、
    perf/lazy-above-fold
    、
    perf/render-blocking
    、
    perf/critical-request-chains
    、
    perf/preconnect
    、
    perf/ttfb
    。
  2. 资源体积:
    perf/total-byte-weight
    、
    perf/js-file-size
    、
    perf/css-file-size
    、
    perf/duplicate-js
    、
    perf/legacy-js
    、
    perf/unminified-js
    、
    perf/unminified-css
    、
    perf/content-in-js-bundle
    、
    perf/framework-data-payload
    、
    images/image-file-size
    、
    images/modern-format
    、
    images/responsive-size
    。
  3. 传输:
    perf/compression
    、
    perf/asset-compression
    、
    perf/cache-headers
    、
    perf/bad-caching
    、
    perf/http2
    。
  4. 稳定性与响应性:
    perf/cls-hints
    、
    images/dimensions
    、
    perf/font-loading
    、
    perf/font-delivery
    、
    perf/inp-hints
    、
    perf/dom-size
    。
  5. 基础清理:
    perf/source-maps
    、
    perf/js-libraries
    、
    perf/js-redirects
    、
    images/lazy-loading
    、
    images/offscreen-lazy
    。
不要对主图(最大图片)使用懒加载:审计会将此标记为问题,而且这是常见的性能回退。每条规则的具体修复方法请参阅其文档页面。

Where the fix usually lives

修复通常位于哪里

StackLook here
Next.js
next/image
(
priority
on the hero,
sizes
),
next/font
,
next/dynamic
for heavy client components, third-party
<Script strategy>
, bundle analyzer for duplicate packages
WordPressone caching plugin (not several), an image optimization plugin or service, removing unused plugins and page-builder widgets, theme scripts loading on every page, a CDN
Shopifytheme assets and Liquid, uninstalling apps (each can inject scripts; removing the app may leave code in
theme.liquid
), image sizes via the
image_url
filter
Webflowimage settings and formats, removing unused interactions and custom code, font loading settings
Cloudflarecaching rules and cache TTLs, compression (Brotli), HTTP/2 and HTTP/3, image resizing
Vercel / Netlify
headers
for
Cache-Control
on hashed assets (
public, max-age=31536000, immutable
), edge caching, image optimization
技术栈优先检查
Next.js
next/image
(首屏主图使用
priority
、
sizes
)、
next/font
、使用
next/dynamic
加载较重的客户端组件、第三方
<Script strategy>
、使用 bundle analyzer 查找重复依赖包
WordPress一个缓存插件(不要使用多个)、图片优化插件或服务、移除未使用的插件和页面构建器小部件、每个页面都会加载的主题脚本、CDN
Shopify主题资源和 Liquid、卸载应用(每个应用都可能注入脚本;卸载应用后,代码仍可能留在
theme.liquid
中)、通过
image_url
过滤器调整图片尺寸
Webflow图片设置和格式、移除未使用的交互和自定义代码、字体加载设置
Cloudflare缓存规则和缓存 TTL、压缩(Brotli)、HTTP/2 和 HTTP/3、图片调整
Vercel / Netlify为带哈希的资源设置
headers
中的
Cache-Control
(
public, max-age=31536000, immutable
)、边缘缓存、图片优化

Prove it

验证改进

Re-audit with
--refresh
after the deploy (cached pages would show the old numbers), then compare with the baseline:
squirrel report --diff <baseline-audit-id> --format llm
. Report the before and after score and the specific rules that cleared.
部署后,使用
--refresh
重新审计(缓存页面会显示旧数值),然后与基线进行比较:
squirrel report --diff <baseline-audit-id> --format llm
。报告修复前后的得分以及已清除的具体规则。

Stop condition

停止条件

Stop when error-severity
perf
findings are cleared on a
--level full
re-audit, the remaining warnings are listed with their cost and effort, and the user has been told lab-style checks do not replace field data. To stop it regressing, see
website-ci-gate
(
--fail-on 'score:perf<80'
style gates).
当
--level full
重新审计后,严重级别为错误的
perf
检查结果均已清除,列出剩余警告及其成本和工作量,并告知用户实验室检查(lab-style checks)不能替代现场数据(field data)时,停止本次修复。为防止问题再次出现,请参阅
website-ci-gate
(类似
--fail-on 'score:perf<80'
的门禁)。

Hand off

交接

Broken assets and links:
broken-link-checker
. Anything else, and the fix loop:
audit-website
.
损坏的资源与链接:
broken-link-checker
。其他问题以及整个修复循环:
audit-website
。