// Analyzes and optimizes Astro islands architecture for minimal client-side JavaScript, ensuring components use correct hydration directives based on interactivity requirements.
| name | astro-islands-optimizer |
| description | Analyzes and optimizes Astro islands architecture for minimal client-side JavaScript, ensuring components use correct hydration directives based on interactivity requirements. |
| version | 1.0.0 |
| tags | ["astro","performance","react","islands"] |
Scan all .astro and .tsx components to identify:
# Find all client: directives
rg "client:(load|idle|visible|media|only)" -g "*.astro" --json
Classification Matrix:
| Component | Current Directive | Recommended | Justification |
|---|---|---|---|
| ThemeToggle | client:load | client:idle | Not critical for FCP |
| CookieBanner | client:load | client:idle | Can defer |
| ContactForm | client:load | client:visible | Below fold |
# Build and analyze
npm run build
# Check output for JavaScript bundle sizes
ls -lh dist/_astro/*.js
Target: < 50KB initial JavaScript bundle
---
// Header.astro - BEFORE
import Navigation from '@components/Navigation.tsx';
---
<Navigation client:load /> <!-- โ Hydrates immediately -->
// AFTER
<Navigation client:idle /> <!-- โ
Hydrates when idle -->
---
// Below-fold heavy component
import SkillsChart from '@components/SkillsChart.tsx';
---
<SkillsChart client:visible /> <!-- โ
Only when visible -->
npm run build completes successfully