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.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "responsive-images" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-responsive-images

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

PatternApproachKey Points
Responsive sizingsrcset with width descriptors (w) + sizesBrowser selects optimal image for viewport and DPR
Modern formats<picture> with AVIF, WebP, JPEG sourcesAVIF saves 70%, WebP saves 50% vs JPEG
Art direction<picture> with media queriesDifferent crops per viewport
LCP hero imageloading="eager" + fetchpriority="high"Prioritize download for Core Web Vitals
Below-fold imagesloading="lazy"Defer until near viewport
Prevent CLSwidth + height attributesBrowser reserves space before load
Fixed containersobject-fit: cover or containMaintain aspect ratio in constrained space
Format fallbackAVIF, WebP, JPEG source orderBest compression first, universal fallback last

Recommended Image Sizes

Use CaseWidths to GenerateSizes Attribute
Full-width hero800w, 1200w, 1600w, 2400w100vw
Content width400w, 800w, 1200w(max-width: 768px) 100vw, 800px
Grid cards (3-col)300w, 600w, 900w(max-width: 768px) 100vw, 33vw
Sidebar thumbnail150w, 300w150px

Loading Strategy

Image PositionloadingfetchpriorityWhy
Hero/LCPeagerhighOptimize LCP, prioritize download
Above fold (not LCP)eageromitLoad normally
Below foldlazyomitDefer until near viewport
Off-screen carousellazyomitDefer until interaction

Format Comparison

FormatQualityFile SizeBrowser SupportUse Case
JPEGGoodMedium100%Photos, complex images
PNGLosslessLarge100%Logos, transparency
WebPExcellentSmall96%+Modern browsers, photos
AVIFExcellentSmallest93%+Newest format, fallback required

Common Mistakes

MistakeCorrect Pattern
Omitting width and height attributes on img elementsAlways include width and height to prevent CLS layout shift
Lazy loading the LCP hero imageUse loading="eager" and fetchpriority="high" for LCP images
Using density descriptors (1x, 2x) for variable-width imagesUse width descriptors (400w, 800w) with a sizes attribute
Missing alt text on content imagesProvide descriptive alt text; use alt="" only for decorative images
Serving only JPEG without modern format fallbacksUse <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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

playwright

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

ui-ux-polish

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

tanstack-form

No summary provided by upstream source.

Repository SourceNeeds Review