image-optimization-requirements

A rule set for loading and sizing images on webpages, especially the first large image users see. That first visible image is often called the largest contentful paint, or LCP, image.

In plain words
What is it for?
Use it when implementing hero images and other early-page images. It specifies eager loading, high fetch priority, dimensions, responsive image handling, and a 100 KB pre-LCP budget.
Why use it?
It helps reduce the data downloaded before the page becomes useful and avoids making the main image load too late or at an unsuitable size.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/adobecom/express-milo/image-optimization-requirements
Clone the repo
git clone --depth 1 https://github.com/adobecom/express-milo

Made for: Cursor.

Per session 3,013 This file is loaded in full into every session.
When invoked 3,013 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.03013 $0.03013
Opus 5 $0.01507 $0.01507
Sonnet 5 $0.00603 $0.00603
Haiku 4.5 $0.00301 $0.00301

Measured 2d ago against content hash b3c361e2d74a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

image-optimization-requirements scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to image-optimization-requirements — 78 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/image-optimization-requirements.mdc · 370 lines

How it starts

The opening of the file, as written. The whole thing — 370 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Image Optimization Performance Rules - Three-Phase Strategy

APPLY: EVERY QUERY - CRITICAL PERFORMANCE RULE

AEM Bandwidth Budget Management (CRITICAL)

Based on AEM's performance guidelines:

  • 100kb total payload before LCP including all images, CSS, JS
  • Single origin only before LCP (no CDN/external image connections)
  • LCP target: 1560ms on mobile for Lighthouse 100 score

Phase E (Eager) - LCP Image Optimization (REQUIRED)

For first section hero/marquee images that are LCP candidates:

// ✅ REQUIRED for LCP candidate images (Phase E)
const optimizeLCPImage = (img, block) => {
  const isFirstSection = block.closest('.section') === document.querySelector('.section');
  const isFirstImage = img === block.querySelector('img');
  
  if (isFirstSection && isFirstImage) {
    // Phase E: Critical LCP optimization
    img.removeAttribute('loading');
    img.setAttribute('loading', 'eager');  
    img.setAttribute('fetchpriority', 'high');
    
    // Calculate optimal size for bandwidth budget
    const optimalWidth = getOptimalImageSize();
    const aspectRatio = getImageAspectRatio(img);
    
    img.setAttribute('width', optimalWidth);
    img.setAttribute('height', Math.round(optimalWidth * aspectRatio));
    
    // Preload only if within bandwidth budget
    const estimatedSize = estimateImagePayload(img.src, optimalWidth);
    if (payloadTracker.canLoadResource(estimatedSize)) {
      preloadLCPImage(img.src, optimalWidth);
    } else {
      console.warn('LCP image exceeds bandwidth budget, consider optimization');
    }
  }
};

// ✅ REQUIRED - Bandwidth-aware image preloading
const preloadLCPImage = (src, width) => {
  const link = document.createElement('link');
  link.rel = 'preload';
  link.as = 'image';
  link.href = `${src}?width=${width}&format=webp&optimize=medium`;
  link.fetchPriority = 'high';
  document.head.appendChild(link);
};

Bandwidth Budget Calculation (REQUIRED)

Read the full file on GitHub · 370 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 370 lines · 3,013 tokens per session scan A b3c361e2d74a

Subscribe to this mod's changes

image-optimization-requirements is a cursor rule published in the GitHub repository adobecom/express-milo (6 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 3,013 tokens to every session, about $0.0151 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to image-optimization-requirements, differing in 78 lines, and is treated as a copy.