Selective targeting
Imgx processes only images marked with the configured `data-*` attribute and ignores every other image in the document.
Imgx is a lightweight, framework-agnostic library for image loading on the web. It targets only opted-in images, adds lazy loading, transitions, retry logic, fallbacks, and pluggable renderers, and leaves everything else alone.
Focused features that reflect the current codebase and project goals, without inflated claims.
Imgx processes only images marked with the configured `data-*` attribute and ignores every other image in the document.
Use global defaults, per-image `data-*` overrides, and programmatic per-instance overrides without losing fallback behavior.
Uses `IntersectionObserver` when available and still loads correctly in environments where it is not supported.
Ships with skeleton, SVG animation, blur preview, dominant color, and fallback renderers in a pluggable system.
Supports fade, blur, and scale transitions, plus retry attempts, delays, and fallback source rotation.
Includes network-aware auto mode and cache-aware decisions to favor lighter behavior where it makes sense.
Imgx is meant to stay small, predictable, and easy to extend.
Use the source modules during development or the generated CDN build for direct browser usage.
<img
data-imgx
data-imgx-src="/images/photo-large.jpg"
data-imgx-preview="/images/photo-preview.jpg"
alt="Example photo"
width="1200"
height="800"
/>
<script type="module">
import imgx from "./src/index.js";
</script>
<script src="./dist/imgx.min.js"></script>
<script>
const gallery = Imgx.createImgx({
placeholder: {
renderer: "skeleton"
}
});
gallery.init();
</script>
Common real-world patterns that match the current library behavior.
<img
data-imgx
data-imgx-src="/images/hero.jpg"
data-imgx-priority="high"
alt="Hero"
width="1600"
height="900"
/>
<img
data-imgx
data-imgx-src="/images/card.jpg"
data-imgx-preview="/images/card-preview.jpg"
data-imgx-renderer="blurPreview"
data-imgx-transition="blur"
alt="Card"
/>
<img
data-imgx
data-imgx-src="/images/primary.jpg"
data-imgx-fallback="/images/fallback-a.jpg,/images/fallback-b.jpg"
data-imgx-retry-attempts="2"
data-imgx-retry-delay="800"
alt="Example"
/>
import { createImgx } from "@amaanwarsi/imgx";
const productImages = createImgx({
targetAttribute: "data-product-img"
});
productImages.init();
The project docs are split by usage, API, and renderer behavior so the core path stays easy to scan.
Browse the complete web docs for setup, API surface, overrides, renderers, and examples.
Quick path for first use, rescanning, custom target attributes, and common per-image patterns.
Read the current exports, instance methods, lifecycle states, and top-level config areas.