responsive-images
Implement performant responsive images with srcset, sizes, lazy loading, and modern formats (WebP, AVIF). Covers aspect-ratio for CLS prevention, picture element for art direction, and fetchpriority for LCP optimization. Use when adding images to pages, optimizing Core Web Vitals, preventing layout shift, implementing art direction, or converting to modern formats.
What this skill does
# Responsive Images ## Overview Responsive images serve the right image size and format based on viewport, device pixel ratio, and browser capabilities. Proper implementation prevents layout shift (CLS), optimizes Largest Contentful Paint (LCP), and reduces bandwidth by 50-70% with modern formats. **When to use:** Any page with images, especially content images, hero images, product photos, and gallery layouts. **When NOT to use:** Inline SVG icons, CSS background patterns, or canvas-rendered graphics. ## Quick Reference | Pattern | Approach | Key Points | | ----------------- | --------------------------------------------- | -------------------------------------------------- | | Responsive sizing | `srcset` with width descriptors (w) + `sizes` | Browser selects optimal image for viewport and DPR | | Modern formats | `<picture>` with AVIF, WebP, JPEG sources | AVIF saves 70%, WebP saves 50% vs JPEG | | Art direction | `<picture>` with `media` queries | Different crops per viewport | | LCP hero image | `loading="eager"` + `fetchpriority="high"` | Prioritize download for Core Web Vitals | | Below-fold images | `loading="lazy"` | Defer until near viewport | | Prevent CLS | `width` + `height` attributes | Browser reserves space before load | | Fixed containers | `object-fit: cover` or `contain` | Maintain aspect ratio in constrained space | | Format fallback | AVIF, WebP, JPEG source order | Best compression first, universal fallback last | ## Recommended Image Sizes | Use Case | Widths to Generate | Sizes Attribute | | ------------------ | ------------------------- | --------------------------------- | | Full-width hero | 800w, 1200w, 1600w, 2400w | `100vw` | | Content width | 400w, 800w, 1200w | `(max-width: 768px) 100vw, 800px` | | Grid cards (3-col) | 300w, 600w, 900w | `(max-width: 768px) 100vw, 33vw` | | Sidebar thumbnail | 150w, 300w | `150px` | ## Loading Strategy | Image Position | loading | fetchpriority | Why | | -------------------- | ------- | ------------- | --------------------------------- | | Hero/LCP | `eager` | `high` | Optimize LCP, prioritize download | | Above fold (not LCP) | `eager` | omit | Load normally | | Below fold | `lazy` | omit | Defer until near viewport | | Off-screen carousel | `lazy` | omit | Defer until interaction | ## Format Comparison | Format | Quality | File Size | Browser Support | Use Case | | ------ | --------- | --------- | --------------- | -------------------------------- | | JPEG | Good | Medium | 100% | Photos, complex images | | PNG | Lossless | Large | 100% | Logos, transparency | | WebP | Excellent | Small | 96%+ | Modern browsers, photos | | AVIF | Excellent | Smallest | 93%+ | Newest format, fallback required | ## Common Mistakes | Mistake | Correct Pattern | | ------------------------------------------------------------ | --------------------------------------------------------------------- | | Omitting width and height attributes on img elements | Always include `width` and `height` to prevent CLS layout shift | | Lazy loading the LCP hero image | Use `loading="eager"` and `fetchpriority="high"` for LCP images | | Using density descriptors (1x, 2x) for variable-width images | Use width descriptors (400w, 800w) with a `sizes` attribute | | Missing alt text on content images | Provide descriptive alt text; use `alt=""` only for decorative images | | Serving only JPEG without modern format fallbacks | Use `<picture>` with AVIF and WebP sources falling back to JPEG | ## Delegation - **Audit a page for responsive image issues and CLS problems**: Use `Explore` agent to scan HTML for missing attributes, incorrect loading strategies, and format gaps - **Convert all images on a page to use picture element with modern formats**: Use `Task` agent to rewrite img tags with AVIF/WebP/JPEG fallback chain - **Plan an image optimization pipeline for a multi-page site**: Use `Plan` agent to design srcset breakpoints, format conversion workflow, and CDN integration ## References - [srcset, sizes, and width descriptor patterns](references/srcset-sizes.md) - [Picture element and art direction](references/picture-element.md) - [Modern image formats: WebP, AVIF, and conversion tools](references/modern-formats.md) - [Lazy loading, fetchpriority, and LCP optimization](references/lazy-loading.md) - [Aspect ratio, object-fit, and CLS prevention](references/aspect-ratio.md)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.