unpic-img

repository·main·Indexed 24 days ago

https://github.com/ascorbic/unpic-img

A cross-framework component library that provides highly optimized, responsive <img> tags by leveraging existing image CDNs to deliver best-practice image performance without complex build steps or heavy client-side JavaScript.

Tokens
41.2K
Snippets
119
Records
233
Agent score
83%

What's inside unpic-img

  1. Overview of unpic-img features

    main

    unpic-img is a multi-framework component designed for responsive, high-performance images using existing image CDNs or CMSs without requiring a build step.

    Key features include:

    • Native HTML: Generates a single <img /> tag with no extra wrapper elements or runtime JavaScript, making it easy to style.
    • Automatic Responsiveness: Automatically generates correct srcset and sizes attributes.
    • Layout Management: Handles fixed, constrained, and full width layouts while preserving aspect ratio to avoid layout shift.
    • Performance Optimizations: Uses native lazy loading (loading="lazy"), async decoding (decoding="async"), and high priority fetching for important images.
    • Modern Formats: Delivers WebP and AVIF if supported by the browser.
    • CDN Integration: Uses unpic to support major CDNs and CMSs like Cloudinary, Imgix, Contentful, and Shopify.
  2. Overview of @unpic/qwik features

    main

    The @unpic/qwik package provides a Qwik component that generates a standard, responsive <img> tag. Key capabilities include:

    • Responsive Images: Automatically generates srcset and sizes attributes and handles resizing while preserving aspect ratio.
    • Performance: Uses native lazy loading, async decoding for offscreen images, and supports eager loading/high priority fetching for critical images.
    • Modern Formats: Delivers WebP and AVIF if supported by the browser.
    • Layout Support: Handles fixed, constrained, and full width layouts.
    • Zero Build Step: Works with existing image CDNs (like Cloudinary, Imgix, and Shopify) via the unpic core logic without requiring server-side rendering or extra configuration.
    • Placeholders: Can generate low-res background images for blurred placeholder effects.
    • Lightweight: Renders only an <img> tag with no extra wrapper elements or runtime JavaScript.
  3. Overview of @unpic/webc features

    main

    The @unpic/webc component provides high-performance, responsive images for WebC environments like Eleventy. Key capabilities include:

    • Native HTML: Generates a standard <img> tag with no extra elements or runtime JavaScript.
    • Responsive Automation: Automatically generates srcset and sizes attributes and handles aspect ratio preservation.
    • Performance: Uses native lazy loading, async decoding, and supports eager loading/high priority fetching for critical images.
    • Layout Support: Handles fixed, constrained, and full width layouts.
    • CDN Integration: Uses unpic to support major CDNs and CMSs (e.g., Cloudinary, Imgix, Shopify) without requiring a build step or additional configuration.
    • Modern Formats: Delivers WebP and AVIF based on browser support.
    • Placeholders: Can generate low-res background images for blurred placeholder effects.
  4. What is unpic-img?

    main

    unpic-img is a multi-framework component library designed for displaying high-performance, responsive images. It works by automatically detecting the image host (CDN or CMS) and using that host's specific API to generate optimized srcset and src attributes. It also generates necessary CSS to ensure correct aspect ratios and prevent layout shifts.

    <Image
      src="https://cdn.shopify.com/static/sample-images/bath.jpeg"
      width={400}
      height={300}
      alt="A lovely bath"
    />
  5. Overview of the Unpic ecosystem

    main

    Unpic is a collection of tools designed to simplify working with images on the web. The ecosystem is divided into several key parts:

    • Unpic components: A set of image components available for ten different frontend frameworks (including React, Angular, Vue, Svelte, Astro, etc.) to handle image optimization automatically.
    • Unpic lib: A core library containing functions for detecting, parsing, and generating URLs for over 20 different image providers (CMSs, hosting providers, and image CDNs).
    • Unpic placeholder: A utility to generate placeholders for lazy-loaded images.
    • Unpic pixels: A utility to load and decode raw image data.

    Developers can use the framework-specific components for UI integration or the core library for low-level URL manipulation and provider detection.

  6. Overview of unpic-img

    main

    unpic-img is a cross-framework component library designed for responsive, high-performance images. It works by leveraging existing image CDNs or CMSs to handle resizing and formatting at the edge, rather than requiring local build steps or server-side processing.

    Key benefits include:

    • Zero Runtime JS: It generates a standard <img> tag without extra wrapper elements or client-side JavaScript by default.
    • Automatic Responsiveness: It automatically generates correct srcset and sizes attributes.
    • Performance Optimized: Uses native browser features like loading="lazy", decoding="async", and fetchpriority to optimize delivery.
    • Layout Stability: Uses pure CSS to handle responsive resizing and preserve aspect ratios, preventing layout shifts.
    • Modern Formats: Supports delivering WebP and AVIF based on browser support.
  7. Features of @unpic/lit

    main

    The @unpic/lit component provides several high-performance image features:

    • Responsive Images: Automatically generates correct srcset and sizes attributes.
    • Layout Support: Handles fixed, constrained, and full width layouts.
    • Performance: Uses native lazy loading, async decoding for offscreen images, and eager loading/high priority fetching for important images.
    • Modern Formats: Delivers WebP and AVIF if supported by the browser.
    • CDN Integration: Uses the unpic library to support CDNs like Cloudinary, Imgix, and Shopify without a build step.
    • Placeholders: Can generate a low-res background image for a blurred placeholder effect.
    • Lightweight: Renders as a standard <img> tag with no extra wrapper elements or runtime JavaScript overhead.
  8. Key features of @unpic/svelte

    main

    The @unpic/svelte component provides several performance and usability benefits:

    • Native HTML: Generates a standard <img> tag with no extra wrapper elements or runtime JavaScript, making it easy to style.
    • Responsive Images: Automatically generates correct srcset and sizes attributes and handles aspect ratio preservation.
    • Performance: Uses native lazy loading, async decoding, and supports modern formats like WebP and AVIF.
    • Layout Support: Handles fixed, constrained, and full width image layouts.
    • Priority Loading: Supports eager loading and high priority fetching for critical images.
    • CDN Integration: Uses unpic to detect and resize images from most major CDNs and CMSs (e.g., Cloudinary, Imgix, Shopify) without additional configuration or build steps.
    • Placeholders: Can generate a low-res background image for blurred placeholder effects.
  9. Features of @unpic/solid

    main

    The @unpic/solid component provides several high-performance image features:

    • Native HTML: Renders a standard <img> tag with no extra wrapper elements or runtime JavaScript, making it easy to style.
    • Responsive Automation: Automatically generates correct srcset and sizes attributes.
    • Layout Support: Handles fixed, constrained, and full width layouts while preserving aspect ratio.
    • Performance Optimization: Uses native lazy loading, async decoding for offscreen images, and eager loading/high priority fetching for important images.
    • Modern Formats: Delivers WebP and AVIF if supported by the browser.
    • CDN Integration: Uses unpic to support most image CDNs and CMSs (including Cloudinary, Imgix, and Shopify) without requiring a build step or additional configuration.
    • Placeholders: Can generate a low-res background image for a blurred placeholder effect.
  10. Features of @unpic/preact

    main

    The @unpic/preact component provides several high-performance image features:

    • Native HTML: Generates a standard <img> tag with no extra elements or runtime JavaScript, making it easy to style.
    • Responsive Automation: Automatically generates correct srcset and sizes attributes and handles responsive resizing while preserving aspect ratio.
    • Performance Optimizations: Uses native lazy loading and async decoding for offscreen images; supports eager loading and high priority fetching for critical images.
    • Modern Formats: Delivers modern image formats like WebP and AVIF if supported by the browser.
    • Zero Build Step: Works with your existing image CDN or CMS (e.g., Cloudinary, Imgix, Shopify) without requiring additional configuration or server-side rendering.
    • Layout Support: Handles fixed, constrained, and full width layouts.
    • Placeholders: Can generate a low-res background image for a blurred placeholder effect.
  11. Features of @unpic/angular

    main

    The @unpic/angular directive provides several automated image optimizations:

    • Responsive Images: Automatically generates srcset and sizes attributes.
    • Layout Support: Handles fixed, constrained, and full width layouts.
    • Performance: Uses native lazy loading, async decoding, and supports eager loading/high priority fetching for critical images.
    • Modern Formats: Delivers WebP and AVIF based on browser support.
    • CDN Integration: Uses unpic to detect and resize images from CDNs like Cloudinary, Imgix, and Shopify without a build step.
    • Placeholders: Can generate low-res background images for blurred placeholder effects.
    • Zero Overhead: Renders as a standard <img> tag with no extra wrapper elements.