@istmx/skills 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/bin/cli.js +251 -0
- package/istm/SKILL.md +65 -0
- package/istm-animate/SKILL.md +87 -0
- package/istm-animate/animations/animation_utils.md +280 -0
- package/istm-animate/animations/animations.md +220 -0
- package/istm-animate/animations/core_motion.md +250 -0
- package/istm-animate/animations/examples/README.md +29 -0
- package/istm-animate/animations/examples/nuxt/app/app.vue +3 -0
- package/istm-animate/animations/examples/nuxt/app/composables/useGSAP.ts +91 -0
- package/istm-animate/animations/examples/nuxt/app/pages/index.vue +55 -0
- package/istm-animate/animations/examples/nuxt/nuxt.config.ts +4 -0
- package/istm-animate/animations/examples/nuxt/package.json +18 -0
- package/istm-animate/animations/examples/react/App.jsx +46 -0
- package/istm-animate/animations/examples/react/index.html +12 -0
- package/istm-animate/animations/examples/react/main.jsx +9 -0
- package/istm-animate/animations/examples/react/package.json +21 -0
- package/istm-animate/animations/examples/react/vite.config.js +7 -0
- package/istm-animate/animations/examples/vanilla/index.html +33 -0
- package/istm-animate/animations/examples/vanilla/main.js +36 -0
- package/istm-animate/animations/examples/vue/app.vue +47 -0
- package/istm-animate/animations/examples/vue/index.html +15 -0
- package/istm-animate/animations/examples/vue/main.js +9 -0
- package/istm-animate/animations/examples/vue/package.json +19 -0
- package/istm-animate/animations/examples/vue/vite.config.js +7 -0
- package/istm-animate/animations/framework_motion.md +262 -0
- package/istm-animate/animations/motion.csv +17 -0
- package/istm-animate/animations/motion.md +11 -0
- package/istm-animate/animations/motion_catalog.json +226 -0
- package/istm-animate/animations/motion_performance.md +75 -0
- package/istm-animate/animations/motion_plugins.md +429 -0
- package/istm-animate/animations/react_animations.md +132 -0
- package/istm-animate/animations/scroll_trigger_effects.md +291 -0
- package/istm-animate/animations/timeline_sequencing.md +103 -0
- package/istm-architecture/SKILL.md +109 -0
- package/istm-architecture/frameworks/angular.csv +51 -0
- package/istm-architecture/frameworks/astro.csv +54 -0
- package/istm-architecture/frameworks/avalonia.csv +57 -0
- package/istm-architecture/frameworks/flutter.csv +53 -0
- package/istm-architecture/frameworks/javafx.csv +76 -0
- package/istm-architecture/frameworks/jetpack-compose.csv +53 -0
- package/istm-architecture/frameworks/laravel.csv +51 -0
- package/istm-architecture/frameworks/nextjs.csv +53 -0
- package/istm-architecture/frameworks/nuxtjs.csv +59 -0
- package/istm-architecture/frameworks/react-native.csv +52 -0
- package/istm-architecture/frameworks/react.csv +54 -0
- package/istm-architecture/frameworks/svelte.csv +54 -0
- package/istm-architecture/frameworks/swiftui.csv +51 -0
- package/istm-architecture/frameworks/uwp.csv +56 -0
- package/istm-architecture/frameworks/vue.csv +50 -0
- package/istm-architecture/frameworks/winui.csv +60 -0
- package/istm-architecture/frameworks/wpf.csv +57 -0
- package/istm-architecture/templates/agents.md +229 -0
- package/istm-architecture/templates/architecture.md +111 -0
- package/istm-architecture/templates/design.md +138 -0
- package/istm-architecture/templates/project-overview.md +215 -0
- package/istm-awwward-designer/SKILL.md +43 -0
- package/istm-awwward-designer/libraries/threejs.csv +54 -0
- package/istm-awwward-designer/references/accessibility.md +774 -0
- package/istm-awwward-designer/references/anim-anti-patterns.md +576 -0
- package/istm-awwward-designer/references/animation-map.md +166 -0
- package/istm-awwward-designer/references/animation-standards.md +86 -0
- package/istm-awwward-designer/references/anti-patterns.md +191 -0
- package/istm-awwward-designer/references/color-systems.md +604 -0
- package/istm-awwward-designer/references/css-performance.md +477 -0
- package/istm-awwward-designer/references/descender-safety.md +490 -0
- package/istm-awwward-designer/references/design-audit.md +93 -0
- package/istm-awwward-designer/references/font-loading.md +378 -0
- package/istm-awwward-designer/references/image-optimization.md +440 -0
- package/istm-awwward-designer/references/invention-gate.md +356 -0
- package/istm-awwward-designer/references/micro-interactions.md +825 -0
- package/istm-awwward-designer/references/page-transitions.md +365 -0
- package/istm-awwward-designer/references/performance-standards.md +79 -0
- package/istm-awwward-designer/references/quality-gate.md +103 -0
- package/istm-awwward-designer/references/responsive-design.md +778 -0
- package/istm-awwward-designer/references/scoring-guide.md +201 -0
- package/istm-awwward-designer/references/scroll-patterns.md +668 -0
- package/istm-awwward-designer/references/stitch-brief.md +124 -0
- package/istm-awwward-designer/references/tech-stack.md +204 -0
- package/istm-awwward-designer/references/technical-audit.md +133 -0
- package/istm-awwward-designer/references/technique-families.md +293 -0
- package/istm-awwward-designer/references/testing.md +535 -0
- package/istm-awwward-designer/references/text-animation.md +585 -0
- package/istm-awwward-designer/references/typography.md +504 -0
- package/istm-awwward-designer/references/usability-audit.md +108 -0
- package/istm-awwward-designer/references/visual-standards.md +97 -0
- package/istm-design/SKILL.md +98 -0
- package/istm-design/colors/color_theory.md +293 -0
- package/istm-design/colors/colors.csv +193 -0
- package/istm-design/colors/colors_catalog.json +4034 -0
- package/istm-design/colors/palette.json +21 -0
- package/istm-design/styles/design_system.md +288 -0
- package/istm-design/styles/html-tailwind.csv +56 -0
- package/istm-design/styles/nuxt-ui.csv +71 -0
- package/istm-design/styles/product_design.md +55 -0
- package/istm-design/styles/shadcn.csv +61 -0
- package/istm-design/styles/style.md +12 -0
- package/istm-design/styles/styles.csv +85 -0
- package/istm-design/styles/styles_catalog.json +2018 -0
- package/istm-design/styles/ui-reasoning.csv +162 -0
- package/istm-design/styles/uno.csv +60 -0
- package/istm-design/typography/font_and_font.md +10 -0
- package/istm-design/typography/google-fonts.csv +1924 -0
- package/istm-design/typography/sans_serif_fonts.md +112 -0
- package/istm-design/typography/typography.csv +75 -0
- package/istm-design/typography/typography_catalog.json +964 -0
- package/istm-design/ux/app-interface.csv +31 -0
- package/istm-design/ux/charts.csv +26 -0
- package/istm-design/ux/icons.csv +106 -0
- package/istm-design/ux/landing.csv +35 -0
- package/istm-design/ux/products.csv +193 -0
- package/istm-design/ux/react-performance.csv +45 -0
- package/istm-design/ux/responsive_rules.md +62 -0
- package/istm-design/ux/storytelling.md +47 -0
- package/istm-design/ux/ux-guidelines.csv +100 -0
- package/istm-design/ux/ux_guidelines.json +1190 -0
- package/istm-system-design/SKILL.md +88 -0
- package/istm-system-design/principles/01-architecture-patterns.md +24 -0
- package/istm-system-design/principles/02-database-selection.md +32 -0
- package/istm-system-design/principles/03-api-design.md +25 -0
- package/istm-system-design/principles/04-authentication-security.md +23 -0
- package/istm-system-design/principles/05-caching-performance.md +21 -0
- package/istm-system-design/principles/06-asynchronous-processing.md +17 -0
- package/istm-system-design/principles/07-infrastructure-deployment.md +22 -0
- package/istm-system-design/principles/08-low-level-design.md +35 -0
- package/istm-system-design/principles/09-state-management.md +14 -0
- package/istm-system-design/principles/10-error-handling-and-logging.md +26 -0
- package/istm-system-design/principles/11-testing-strategy.md +18 -0
- package/istm-system-design/principles/12-seo-and-web-vitals.md +18 -0
- package/istm-system-design/stacks/SETUP.md +82 -0
- package/istm-system-design/stacks/STACK.md +67 -0
- package/istm-system-design/stacks/WORKFLOW.md +84 -0
- package/istm-system-design/templates/api-route.ts.template +32 -0
- package/istm-system-design/templates/migrations.md.template +30 -0
- package/istm-system-design/templates/schema.drizzle.ts.template +17 -0
- package/istm-system-design/templates/schema.prisma.template +28 -0
- package/istm-system-design/templates/trpc-router.ts.template +22 -0
- package/istm-system-design/templates/zod-validators.ts.template +14 -0
- package/istm-workflow/istm-audit/SKILL.md +108 -0
- package/istm-workflow/istm-audit/agent-prompt.md +393 -0
- package/istm-workflow/istm-audit/agents/openai.yaml +7 -0
- package/istm-workflow/istm-audit/modes/area.md +19 -0
- package/istm-workflow/istm-audit/modes/gapfill.md +12 -0
- package/istm-workflow/istm-audit/modes/greenfield.md +24 -0
- package/istm-workflow/istm-audit/modes/tool-skills.md +39 -0
- package/istm-workflow/istm-audit/modes/whole-repo.md +5 -0
- package/istm-workflow/istm-audit/patterns/clean-architecture.md +15 -0
- package/istm-workflow/istm-audit/patterns/domain-driven.md +16 -0
- package/istm-workflow/istm-audit/patterns/functional.md +16 -0
- package/istm-workflow/istm-audit/patterns/solid-oop.md +17 -0
- package/istm-workflow/istm-check/SKILL.md +52 -0
- package/istm-workflow/istm-check/agents/openai.yaml +7 -0
- package/istm-workflow/istm-check/modes/review.md +156 -0
- package/istm-workflow/istm-check/modes/verify.md +197 -0
- package/istm-workflow/istm-check/review-agent-prompt.md +57 -0
- package/istm-workflow/istm-check/review-guide.md +133 -0
- package/istm-workflow/istm-craft/SKILL.md +37 -0
- package/istm-workflow/istm-craft/agent-modes/architecture.md +73 -0
- package/istm-workflow/istm-craft/agent-modes/cross-cutting.md +65 -0
- package/istm-workflow/istm-craft/agent-modes/enhancement.md +45 -0
- package/istm-workflow/istm-craft/agent-modes/feature.md +85 -0
- package/istm-workflow/istm-craft/agent-prompt.md +249 -0
- package/istm-workflow/istm-craft/agents/openai.yaml +7 -0
- package/istm-workflow/istm-craft/internal/after-subagent.md +90 -0
- package/istm-workflow/istm-craft/internal/design-conversation.md +140 -0
- package/istm-workflow/istm-craft/internal/tool-discovery.md +58 -0
- package/istm-workflow/istm-craft/spec-template.md +278 -0
- package/istm-workflow/istm-debug/SKILL.md +102 -0
- package/istm-workflow/istm-debug/agents/openai.yaml +7 -0
- package/istm-workflow/istm-develop/SKILL.md +144 -0
- package/istm-workflow/istm-develop/agents/openai.yaml +7 -0
- package/istm-workflow/istm-develop/checklist.md +95 -0
- package/istm-workflow/istm-develop/flow/build.md +133 -0
- package/istm-workflow/istm-develop/flow/git.md +34 -0
- package/istm-workflow/istm-develop/logical-guide.md +99 -0
- package/istm-workflow/istm-develop/ui/existing.md +23 -0
- package/istm-workflow/istm-develop/ui/generate.md +131 -0
- package/istm-workflow/istm-develop/ui/image.md +41 -0
- package/istm-workflow/istm-develop/ui/implementation.md +281 -0
- package/istm-workflow/istm-develop/ui/mcp.md +11 -0
- package/istm-workflow/istm-develop/ui-guide.md +164 -0
- package/istm-workflow/istm-document/SKILL.md +123 -0
- package/istm-workflow/istm-document/agent-prompt.md +57 -0
- package/istm-workflow/istm-document/agents/openai.yaml +7 -0
- package/istm-workflow/istm-document/templates/changelog.md +54 -0
- package/istm-workflow/istm-document/templates/postmortem.md +58 -0
- package/istm-workflow/istm-document/templates/pr.md +43 -0
- package/istm-workflow/istm-document/templates/release-note.md +41 -0
- package/istm-workflow/istm-scope/SKILL.md +100 -0
- package/istm-workflow/istm-scope/agents/openai.yaml +7 -0
- package/istm-workflow/istm-scope/approaches/facade.md +33 -0
- package/istm-workflow/istm-scope/approaches/journey.md +31 -0
- package/istm-workflow/istm-scope/approaches/skateboard.md +33 -0
- package/istm-workflow/istm-scope/approaches/tracer-bullet.md +34 -0
- package/istm-workflow/istm-scope/modes/add.md +14 -0
- package/istm-workflow/istm-scope/modes/plan-brownfield.md +11 -0
- package/istm-workflow/istm-scope/modes/plan-greenfield.md +20 -0
- package/istm-workflow/istm-scope/modes/plan-monorepo.md +8 -0
- package/istm-workflow/istm-scope/modes/plan.md +120 -0
- package/istm-workflow/istm-scope/modes/replan.md +13 -0
- package/istm-workflow/istm-scope/scope-template.md +148 -0
- package/istm-workflow/istm-sync/SKILL.md +166 -0
- package/istm-workflow/istm-sync/agent-prompt.md +211 -0
- package/istm-workflow/istm-sync/agents/openai.yaml +7 -0
- package/istm-workflow/istm-test/SKILL.md +233 -0
- package/istm-workflow/istm-test/agent-prompt.md +62 -0
- package/istm-workflow/istm-test/agents/openai.yaml +7 -0
- package/istm-workflow/istm-test/modes/setup.md +97 -0
- package/istm-workflow/istm-test/writing-guide.md +196 -0
- package/package.json +35 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
# Image Optimization — Deep Dive
|
|
2
|
+
|
|
3
|
+
Images are the largest contributor to page weight. Optimized images can cut LCP by seconds. This guide covers the full image pipeline from generation to delivery.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Image Format Decision Tree
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Is it a photograph or complex image?
|
|
11
|
+
→ AVIF (primary) → WebP (fallback) → JPEG (last resort)
|
|
12
|
+
|
|
13
|
+
Is it a graphic, logo, icon, or needs transparency?
|
|
14
|
+
→ SVG (vector, resolution-independent)
|
|
15
|
+
|
|
16
|
+
Is it a screenshot or needs pixel-perfect detail?
|
|
17
|
+
→ PNG (or AVIF if supported)
|
|
18
|
+
|
|
19
|
+
Is it animated?
|
|
20
|
+
→ AVIF animated OR WebM video loop (not GIF — GIF is obsolete for animation)
|
|
21
|
+
→ GIF: only for decorative loops where file size truly doesn't matter
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Format Comparison (typical 1200×800 photograph)
|
|
25
|
+
|
|
26
|
+
| Format | Quality 80 | Quality 90 | Notes |
|
|
27
|
+
|--------|-----------|-----------|-------|
|
|
28
|
+
| AVIF | ~40KB | ~80KB | Best compression, wide support (>93% global) |
|
|
29
|
+
| WebP | ~80KB | ~150KB | Good fallback, ~30% smaller than JPEG |
|
|
30
|
+
| JPEG | ~120KB | ~200KB | Universal support, worst compression |
|
|
31
|
+
| PNG | ~400KB+ | N/A | Never use for photographs |
|
|
32
|
+
|
|
33
|
+
**Browser support (2024):** AVIF: 93%+ global, WebP: 98%+, AVIF animations: ~88%. Use `<picture>` element for art direction and format fallbacks.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Responsive Images
|
|
38
|
+
|
|
39
|
+
### srcset — Density Variants
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<img
|
|
43
|
+
src="hero-800.avif"
|
|
44
|
+
srcset="
|
|
45
|
+
hero-400.avif 400w,
|
|
46
|
+
hero-800.avif 800w,
|
|
47
|
+
hero-1200.avif 1200w,
|
|
48
|
+
hero-1600.avif 1600w
|
|
49
|
+
"
|
|
50
|
+
sizes="
|
|
51
|
+
(max-width: 600px) 100vw,
|
|
52
|
+
(max-width: 1200px) 80vw,
|
|
53
|
+
1200px
|
|
54
|
+
"
|
|
55
|
+
alt="Hero image"
|
|
56
|
+
width="1600"
|
|
57
|
+
height="900"
|
|
58
|
+
fetchpriority="high"
|
|
59
|
+
>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### sizes Attribute Guide
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<!-- Full width on mobile, 2/3 width on desktop -->
|
|
66
|
+
<img srcset="..." sizes="(max-width: 768px) 100vw, 66vw">
|
|
67
|
+
|
|
68
|
+
<!-- Fixed width on mobile, 600px on desktop -->
|
|
69
|
+
<img srcset="..." sizes="(max-width: 768px) 100vw, 600px">
|
|
70
|
+
|
|
71
|
+
<!-- 100vmin for square-ish crops -->
|
|
72
|
+
<img srcset="..." sizes="100vmin">
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### The sizes Formula
|
|
76
|
+
|
|
77
|
+
`sizes` tells the browser how wide the image will render — it does NOT resize the image. The browser uses this + `srcset` to pick the smallest image that covers the slot:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Image candidate selected = max(available viewport width × device pixel ratio, natural width)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## The <picture> Element — Art Direction + Format Fallback
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<picture>
|
|
89
|
+
<!-- AVIF with WebP and JPEG fallbacks -->
|
|
90
|
+
<source
|
|
91
|
+
type="image/avif"
|
|
92
|
+
srcset="
|
|
93
|
+
hero-400.avif 400w,
|
|
94
|
+
hero-800.avif 800w,
|
|
95
|
+
hero-1200.avif 1200w
|
|
96
|
+
"
|
|
97
|
+
sizes="100vw"
|
|
98
|
+
>
|
|
99
|
+
<source
|
|
100
|
+
type="image/webp"
|
|
101
|
+
srcset="
|
|
102
|
+
hero-400.webp 400w,
|
|
103
|
+
hero-800.webp 800w,
|
|
104
|
+
hero-1200.webp 1200w
|
|
105
|
+
"
|
|
106
|
+
sizes="100vw"
|
|
107
|
+
>
|
|
108
|
+
<img
|
|
109
|
+
src="hero-800.jpg"
|
|
110
|
+
alt="Hero image"
|
|
111
|
+
width="1600"
|
|
112
|
+
height="900"
|
|
113
|
+
fetchpriority="high"
|
|
114
|
+
>
|
|
115
|
+
</picture>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Art Direction Example
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<picture>
|
|
122
|
+
<!-- Landscape for desktop -->
|
|
123
|
+
<source
|
|
124
|
+
media="(min-width: 768px)"
|
|
125
|
+
srcset="hero-landscape.avif"
|
|
126
|
+
type="image/avif"
|
|
127
|
+
>
|
|
128
|
+
<!-- Portrait crop for mobile -->
|
|
129
|
+
<source
|
|
130
|
+
media="(max-width: 767px)"
|
|
131
|
+
srcset="hero-portrait.avif"
|
|
132
|
+
type="image/avif"
|
|
133
|
+
>
|
|
134
|
+
<img src="hero-portrait.avif" alt="Hero" fetchpriority="high">
|
|
135
|
+
</picture>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## fetchpriority — The LCP Multiplier
|
|
141
|
+
|
|
142
|
+
The `fetchpriority` attribute (part of the Fetch Priority API) tells the browser how important a resource is relative to others.
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<!-- HIGH — LCP element, preload it -->
|
|
146
|
+
<img src="hero.avif" fetchpriority="high">
|
|
147
|
+
|
|
148
|
+
<!-- LOW — decorative, below fold -->
|
|
149
|
+
<img src="decoration.avif" fetchpriority="low">
|
|
150
|
+
|
|
151
|
+
<!-- AUTO — browser decides (default) -->
|
|
152
|
+
<img src="normal.avif" fetchpriority="auto">
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Preload + fetchpriority="high" on the LCP element is the single highest-ROI optimization in web performance.**
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<head>
|
|
159
|
+
<link rel="preload" as="image" href="hero.avif" fetchpriority="high">
|
|
160
|
+
</head>
|
|
161
|
+
<body>
|
|
162
|
+
<img src="hero.avif" fetchpriority="high" alt="Hero">
|
|
163
|
+
</body>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Lazy Loading
|
|
169
|
+
|
|
170
|
+
### Native Lazy Loading
|
|
171
|
+
|
|
172
|
+
```html
|
|
173
|
+
<!-- Native lazy loading — browser handles it -->
|
|
174
|
+
<img src="below-fold.jpg" loading="lazy" alt="..." width="800" height="600">
|
|
175
|
+
|
|
176
|
+
<!-- Explicit eager (opt out of lazy) -->
|
|
177
|
+
<img src="above-fold.jpg" loading="eager" alt="...">
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### When NOT to Lazy Load
|
|
181
|
+
|
|
182
|
+
- **LCP element** — Ever. Never. It destroys LCP.
|
|
183
|
+
- **First 2-3 images above the fold** — Load these eagerly
|
|
184
|
+
- **Critical UI elements** — Logos, navigation icons, hero images
|
|
185
|
+
|
|
186
|
+
### JavaScript Lazy Loading (Intersection Observer)
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
const lazyImages = document.querySelectorAll('img[data-src]');
|
|
190
|
+
|
|
191
|
+
const imageObserver = new IntersectionObserver((entries, observer) => {
|
|
192
|
+
entries.forEach(entry => {
|
|
193
|
+
if (entry.isIntersecting) {
|
|
194
|
+
const img = entry.target;
|
|
195
|
+
img.src = img.dataset.src;
|
|
196
|
+
img.removeAttribute('data-src');
|
|
197
|
+
observer.unobserve(img);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}, {
|
|
201
|
+
rootMargin: '200px', // Start loading 200px before entering viewport
|
|
202
|
+
threshold: 0.01
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
lazyImages.forEach(img => imageObserver.observe(img));
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Native Lazy Loading + JS Fallback
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
<img
|
|
212
|
+
src="image.avif"
|
|
213
|
+
loading="lazy"
|
|
214
|
+
decoding="async"
|
|
215
|
+
alt="..."
|
|
216
|
+
>
|
|
217
|
+
<!-- decoding="async" allows the browser to decode off the main thread -->
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Blur-Up Placeholders (LQIP)
|
|
223
|
+
|
|
224
|
+
Low Quality Image Placeholders show a tiny blurred version while the full image loads.
|
|
225
|
+
|
|
226
|
+
### CSS Blur-Up
|
|
227
|
+
|
|
228
|
+
```css
|
|
229
|
+
.blur-up {
|
|
230
|
+
filter: blur(20px);
|
|
231
|
+
transition: filter 0.4s ease-out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.blur-up.loaded {
|
|
235
|
+
filter: blur(0);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<img
|
|
241
|
+
class="blur-up"
|
|
242
|
+
src="tiny-blur.avif"
|
|
243
|
+
data-src="full-image.avif"
|
|
244
|
+
alt="..."
|
|
245
|
+
>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
img.onload = () => img.classList.add('loaded');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Solid Color Placeholder
|
|
253
|
+
|
|
254
|
+
```css
|
|
255
|
+
/* When you know the dominant color from build-time analysis */
|
|
256
|
+
.hero-image-placeholder {
|
|
257
|
+
background-color: #2d2d2d;
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### SVG Blur-Up (Tiny Base64)
|
|
262
|
+
|
|
263
|
+
```html
|
|
264
|
+
<img
|
|
265
|
+
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxIDEiPjxyZWN0IGZpbGw9IiMzMzMiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiLz48L3N2Zz4="
|
|
266
|
+
data-src="hero.avif"
|
|
267
|
+
alt="..."
|
|
268
|
+
>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Image CDNs
|
|
274
|
+
|
|
275
|
+
Image CDNs transform, optimize, and deliver images from edge locations. For Antigravity builds, use Cloudflare (free tier excellent), Cloudinary, imgix, or Sanity.
|
|
276
|
+
|
|
277
|
+
### Cloudflare Images
|
|
278
|
+
|
|
279
|
+
```html
|
|
280
|
+
<!-- Cloudflare Images delivery -->
|
|
281
|
+
<img src="https://your-domain.com/cdn-cgi/image/width=800,format=avif,quality=80/hero.jpg">
|
|
282
|
+
|
|
283
|
+
<!-- Variant delivery -->
|
|
284
|
+
<img src="https://your-domain.com/cdn-cgi/image/width=800,height=450,fit=cover,format=avif/hero.jpg">
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Cloudinary URL Transform
|
|
288
|
+
|
|
289
|
+
```html
|
|
290
|
+
<!-- Auto-format and quality -->
|
|
291
|
+
<img src="https://res.cloudinary.com/demo/image/fetch/w_800,q_auto,f_avif/https://source-image.jpg">
|
|
292
|
+
|
|
293
|
+
<!-- Crop to face -->
|
|
294
|
+
<img src="https://res.cloudinary.com/demo/image/fetch/w_800,h_800,c_fill,g_face,f_avif,q_auto/https://source-image.jpg">
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### imgix
|
|
298
|
+
|
|
299
|
+
```html
|
|
300
|
+
<!-- Auto format + quality + responsive -->
|
|
301
|
+
<img src="https://example.imgix.net/hero.jpg?w=800&auto=format,compress&fit=crop">
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### CDN Checklist
|
|
305
|
+
|
|
306
|
+
- [ ] Enable AVIF + WebP auto-negotiation
|
|
307
|
+
- [ ] Set `Cache-Control: public, max-age=31536000, immutable` for hashed assets
|
|
308
|
+
- [ ] Use consistent URLs (avoid `?v=timestamp` for immutable content)
|
|
309
|
+
- [ ] Configure responsive breakpoints that match your `srcset`
|
|
310
|
+
- [ ] Set image quality to 75-85 for most content (test visually)
|
|
311
|
+
- [ ] Strip EXIF metadata (it adds bytes without visual value)
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Aspect Ratio — The CLS Prevention Must
|
|
316
|
+
|
|
317
|
+
```css
|
|
318
|
+
/* Method 1: HTML attributes (preferred) */
|
|
319
|
+
<img src="hero.avif" width="1600" height="900" alt="...">
|
|
320
|
+
|
|
321
|
+
/* Method 2: CSS aspect-ratio (when HTML dimensions unknown at build) */
|
|
322
|
+
img {
|
|
323
|
+
aspect-ratio: 16 / 9;
|
|
324
|
+
width: 100%;
|
|
325
|
+
height: auto; /* auto computed from aspect-ratio + width */
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* Method 3: padding-bottom hack (older browsers) */
|
|
329
|
+
.aspect-box {
|
|
330
|
+
position: relative;
|
|
331
|
+
width: 100%;
|
|
332
|
+
padding-bottom: 56.25%; /* 9/16 = 0.5625 */
|
|
333
|
+
}
|
|
334
|
+
.aspect-box > img {
|
|
335
|
+
position: absolute;
|
|
336
|
+
top: 0; left: 0;
|
|
337
|
+
width: 100%; height: 100%;
|
|
338
|
+
object-fit: cover;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* Responsive aspect ratios */
|
|
342
|
+
.ratio-4-3 { aspect-ratio: 4 / 3; }
|
|
343
|
+
.ratio-16-9 { aspect-ratio: 16 / 9; }
|
|
344
|
+
.ratio-1-1 { aspect-ratio: 1 / 1; }
|
|
345
|
+
.ratio-3-4 { aspect-ratio: 3 / 4; }
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Video Optimization
|
|
351
|
+
|
|
352
|
+
```html
|
|
353
|
+
<!-- Video poster — critical for LCP if video is LCP element -->
|
|
354
|
+
<video
|
|
355
|
+
src="hero.mp4"
|
|
356
|
+
poster="hero-poster.avif"
|
|
357
|
+
preload="none"
|
|
358
|
+
muted
|
|
359
|
+
autoplay
|
|
360
|
+
loop
|
|
361
|
+
playsinline
|
|
362
|
+
fetchpriority="high"
|
|
363
|
+
></video>
|
|
364
|
+
|
|
365
|
+
<!-- Lazy load video -->
|
|
366
|
+
<video
|
|
367
|
+
src="hero.mp4"
|
|
368
|
+
poster="hero-poster.avif"
|
|
369
|
+
preload="none"
|
|
370
|
+
loading="lazy"
|
|
371
|
+
muted
|
|
372
|
+
autoplay
|
|
373
|
+
loop
|
|
374
|
+
playsinline
|
|
375
|
+
></video>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Video Best Practices
|
|
379
|
+
|
|
380
|
+
- Always set `poster` attribute — shows immediately while video loads
|
|
381
|
+
- Poster should be AVIF/WebP, generated from first frame
|
|
382
|
+
- Use `preload="none"` for below-fold videos
|
|
383
|
+
- Use `preload="metadata"` for near-fold videos
|
|
384
|
+
- `muted`, `autoplay`, `loop`, `playsinline` for background videos
|
|
385
|
+
- Consider `<source>` elements with format fallbacks
|
|
386
|
+
- For autoplay muted video that IS the LCP element: preload + fetchpriority="high"
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Build-Time Image Processing
|
|
391
|
+
|
|
392
|
+
Use sharp, imagemin, or your bundler's image plugin (Vite's `vite-plugin-imagemin`).
|
|
393
|
+
|
|
394
|
+
```js
|
|
395
|
+
// Example: sharp processing pipeline
|
|
396
|
+
import sharp from 'sharp';
|
|
397
|
+
|
|
398
|
+
const hero = sharp('source/hero.jpg');
|
|
399
|
+
const metadata = await hero.metadata();
|
|
400
|
+
|
|
401
|
+
// Generate AVIF + WebP + JPEG at multiple sizes
|
|
402
|
+
const widths = [400, 800, 1200, 1600];
|
|
403
|
+
|
|
404
|
+
for (const w of widths) {
|
|
405
|
+
await hero
|
|
406
|
+
.clone()
|
|
407
|
+
.resize(w)
|
|
408
|
+
.avif({ quality: 80 })
|
|
409
|
+
.toFile(`dist/hero-${w}.avif`);
|
|
410
|
+
|
|
411
|
+
await hero
|
|
412
|
+
.clone()
|
|
413
|
+
.resize(w)
|
|
414
|
+
.webp({ quality: 80 })
|
|
415
|
+
.toFile(`dist/hero-${w}.webp`);
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## Image Optimization Checklist
|
|
422
|
+
|
|
423
|
+
```plaintext
|
|
424
|
+
□ AVIF primary format for all photographs
|
|
425
|
+
□ WebP fallback for all photographs
|
|
426
|
+
□ JPEG only as last resort fallback
|
|
427
|
+
□ SVG for all icons, logos, vectors
|
|
428
|
+
□ srcset with 3-4 density variants (400w, 800w, 1200w, 1600w)
|
|
429
|
+
□ sizes attribute on every responsive image
|
|
430
|
+
□ fetchpriority="high" on LCP element + preload link in <head>
|
|
431
|
+
□ loading="lazy" on all below-fold images
|
|
432
|
+
□ decoding="async" on all images
|
|
433
|
+
□ width + height attributes OR aspect-ratio CSS on every image
|
|
434
|
+
□ Image CDN for transformation and delivery
|
|
435
|
+
□ Cache-Control: immutable for versioned assets
|
|
436
|
+
□ Blur-up placeholder for hero images
|
|
437
|
+
□ poster attribute on every <video>
|
|
438
|
+
□ No GIF for animation (use WebM/AVIF video)
|
|
439
|
+
□ Build-time processing: sharp, imagemin, or vite-plugin-imagemin
|
|
440
|
+
```
|