agentleFS
casooncasoon/ai-agent-config/skills/web-performance/SKILL.md

web-performance

Skill1 starsChanged 2 months agoMITView on GitHub

Static performance patterns for Astro sites — responsive images, CSS containment, minimal client JS, font loading, and Core Web Vitals targets. Use when writing or reviewing code to prevent performance issues (image sizing, lazy loading, bundle splitting). For live profiling and measurement with Chrome DevTools, use web-perf instead.

11 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 2 are distinctive, and 9 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Only hero / above-the-fold images use loading="eager".

    line 20
  2. Distinctive:

    Prefer WebP (or AVIF for larger hero images).

    line 24
  3. Very specific:

    Avoid filter: blur() on moving elements.

    line 49
  4. Very specific:

    Use transform: translate3d() for GPU compositing.

    line 50
  5. Very specific:

    Keep will-change to the minimum of elements that actually need it.

    line 51
  6. Very specific:

    Prefer CSS animation-timeline: view() over JS scroll handlers.

    line 52
  7. Very specific:

    Use <script> only when truly needed.

    line 60
  8. Very specific:

    Prefer CSS-only solutions: :has(), <details>, popover, <dialog>.

    line 61
  9. Very specific:

    Run @casoon/astro-post-audit after the build to validate assets, duplicates, and structure.

    line 89
  10. Very specific:

    All images have explicit width/height.

    line 110
  11. Distinctive:

    No JS framework shipped for a component that could be pure HTML/CSS.

    line 111

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Web performance

Images

Responsive variants

Generate multiple widths (e.g. 378 w, 756 w, 1200 w) in WebP. Source images at 1024×1024 for blog teasers, 1200×630 for OG images.

Lazy loading

<img src="image.webp" loading="lazy" decoding="async" width="756" height="504" alt="…" />

Only hero / above-the-fold images use loading="eager". Always set width and height to prevent CLS.

Format

Prefer WebP (or AVIF for larger hero images). Let Astro's image service handle format negotiation where possible.

CSS performance

content-visibility for long pages

.article-card {
  content-visibility: auto;
  contain-intrinsic-size: 0 300px;
}

Browsers skip rendering of off-screen cards; contain-intrinsic-size prevents layout shift.

CSS containment

.card { contain: layout paint style; }

Isolates layout and paint calculations to the element.

Animation cost

  • Avoid filter: blur() on moving elements.
  • Use transform: translate3d() for GPU compositing.
  • Keep will-change to the minimum of elements that actually need it.
  • Prefer CSS animation-timeline: view() over JS scroll handlers.

JavaScript

Minimize client JS

Astro renders zero JS by default — keep it that way.

  • Use <script> only when truly needed.
  • Prefer CSS-only solutions: :has(), <details>, popover, <dialog>.
  • Hydrate islands with client:visible or client:idle instead of client:load.

Scroll handlers

// Bad — runs every scroll frame
window.addEventListener('scroll', handler);

// Better — passive
window.addEventListener('scroll', handler, { passive: true });

// Best — CSS scroll-driven animation, no JS
/* .element { animation-timeline: view(); } */

Font loading

@import '@fontsource/inter/latin-400.css';
  • Self-host via @fontsource — no external requests, optimal caching.
  • font-display: swap is already set by @fontsource.
  • Subset to the scripts you actually need (latin, latin-ext, etc.).

Build optimization

  • Run @casoon/astro-post-audit after the build to validate assets, duplicates, and structure.
  • Review Vite's bundle output for large chunks: unintended npm packages in client bundles, duplicate component instances, inline SVGs that should be external.

Core Web Vitals

MetricTargetCommon fix
LCP< 2.5 sPreload hero image, inline critical CSS
CLS< 0.1Explicit width/height on images, contain-intrinsic-size for off-screen cards
INP< 200 msMove work off main thread, reduce JS, prefer CSS interactions

Edge / Cloudflare

  • Static assets: automatic edge caching.
  • Workers: minimize cold starts — avoid heavy npm deps in Worker entry.
  • Images: use cache-control headers consistent with build fingerprints.
  • Sharp is not available on Workers — use Astro's noop image service there.

Review checklist

  • Above-the-fold image preloaded; below-the-fold lazy.
  • All images have explicit width/height.
  • No JS framework shipped for a component that could be pure HTML/CSS.
  • Islands hydrated with the lightest directive that works.
  • Fonts self-hosted, subset, font-display: swap.
  • Core Web Vitals measured on a realistic field run, not just lab.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.