Build on the supported package contract
Use absolutejs-image-optimization-example through its supported public entry points.
absolutejs-image-optimization-examplev0.0.1betaDev ToolsThis project showcases the AbsoluteJS Image component across four frameworks — React, Vue, Svelte, and Angular — plus the data-optimized attribute for plain HTML and HTMX. Each demo page renders the same set of images so you can compare the developer experience and output across all six approaches.
# Private workspace project: ~/abs/examples/image-optimizationThis project showcases the AbsoluteJS Image component across four frameworks — React, Vue, Svelte, and Angular — plus the data-optimized attribute for plain HTML and HTMX. Each demo page renders the same set of images so you can compare the developer experience and output across all six approaches.
Framework — Component / Attribute — Import
React — <Image> — import { Image } from "@absolutejs/absolute/react/components"
Vue — <Image> — import Image from "@absolutejs/absolute/vue/components/Image.vue"
Svelte — <Image> — import Image from "@absolutejs/absolute/svelte/components/Image.svelte"
Angular — import { ImageComponent } from "@absolutejs/absolute/angular/components"
HTML — N/A — uses a build-time attribute on standard tags
HTMX — N/A — same build-time attribute, works with HTMX partial swaps
All four framework components share the same prop interface:
Prop — Type — Default — Description
src — string — — — Required. Image source path (e.g. /assets/jpg/landscape.jpg)
alt — string — — — Required. Alt text for accessibility
width — number — — — Intrinsic image width in pixels
height — number — — — Intrinsic image height in pixels
sizes — string — — — Responsive sizes descriptor (e.g. (max-width: 640px) 100vw, 340px)
priority — boolean — false — Adds a preload link, sets loading="eager" and fetchPriority="high"
fill — boolean — false — Image fills its parent container with object-fit: cover
unoptimized — boolean — false — Bypasses the optimization endpoint and serves the original file
quality — number — 75 — Output quality (0–100) for lossy formats
loading — string — "lazy" — Loading strategy — "lazy" or "eager"
fetchPriority — string — "auto" — Fetch priority hint — "auto", "high", or "low"
For plain HTML and HTMX pages, add the data-optimized attribute to any tag. At build time AbsoluteJS will:
Rewrite src to the optimization endpoint (/_absolute/image)
Generate a responsive srcset with all configured sizes
Add loading="lazy" and decoding="async" automatically
Serve AVIF/WebP variants based on browser support
To skip optimization for a specific image, omit the data-optimized attribute.
Image optimization is configured in absolute.config.ts:
images options
Option — Type — Default — Description
formats — string[] — ["webp"] — Output formats to generate (e.g. ["avif", "webp"])
The optimization endpoint (/_absolute/image) accepts these query parameters at runtime:
Parameter — Description
url — Source image path
w — Target width
q — Quality (0–100)
Built-in defaults
Device sizes: 640, 750, 828, 1080, 1200, 1920, 2048, 3840
Image sizes: 16, 32, 48, 64, 96, 128, 256, 384
Default quality: 75
Each framework renders the same set of examples:
Responsive images — width, height, and sizes for automatic srcset
Priority loading — priority flag for above-the-fold images
Fill mode — fill flag to cover a parent container
Unoptimized — unoptimized flag to bypass processing
Runs Playwright end-to-end tests that verify image optimization output across all frameworks.
Outcomes
Use absolutejs-image-optimization-example through its supported public entry points.
Hardening checklist
Follow in order
For plain HTML and HTMX pages, add the data-optimized attribute to any tag. At build time AbsoluteJS will:
<img
data-optimized
src="/assets/jpg/landscape.jpg"
width="1200"
height="800"
sizes="(max-width: 640px) 100vw, 340px"
alt="Landscape photo"
/>Image optimization is configured in absolute.config.ts:
import { defineConfig } from "@absolutejs/absolute";
export default defineConfig({
images: {
formats: ["avif", "webp"],
},
// Framework source directories
angularDirectory: "./src/frontend/angular",
reactDirectory: "./src/frontend/react",
svelteDirectory: "./src/frontend/svelte",
vueDirectory: "./src/frontend/vue",
htmlDirectory: "./src/frontend/html",
htmxDirectory: "./src/frontend/htmx",
assetsDirectory: "./src/backend/assets",
stylesConfig: "./src/frontend/styles/indexes",
});Scripts declared by this package manifest.