Skip to content

⚡ Bolt: Pre-calculate optimized image urls using getImage() in Astro file - #153

Open
fysp11 wants to merge 1 commit into
mainfrom
bolt/optimize-astro-image-in-react-16601872876506742483
Open

⚡ Bolt: Pre-calculate optimized image urls using getImage() in Astro file#153
fysp11 wants to merge 1 commit into
mainfrom
bolt/optimize-astro-image-in-react-16601872876506742483

Conversation

@fysp11

@fysp11 fysp11 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

💡 What: We are pre-optimizing image URLs on the server (in the .astro file) via import.meta.glob and getImage(). These URLs are passed into the ProjectsView.tsx component which now uses standard HTML <img> tags featuring appropriate performance attributes (loading="lazy" for below the fold elements, loading="eager" and fetchPriority="high" for the first elements in a loop).

🎯 Why: Astro's built-in <Image /> component does not work when used inside React (.tsx) files. The previous implementation fell back to unoptimized image loading, hurting LCP and wasting bandwidth by sending over large source image files (e.g., massive full-size .pngs) instead of automatically scaled-down webp variants.

📊 Impact: Reduces overall image payload size significantly (due to webp formatting + scaling), resulting in noticeably faster loading times and improved Core Web Vitals on the Projects page.

🔬 Measurement: Observe the network tab when loading the Projects page. You should see smaller webp files being downloaded rather than the original source images. Inspect the elements in the grid/list to observe correct loading="eager" vs loading="lazy" tags.


PR created automatically by Jules for task 16601872876506742483 started by @fysp11

Replaced native Astro `<Image>` components inside `ProjectsView.tsx` with standard HTML `<img>` tags populated by URLs properly optimized using Astro's server-side `getImage()` function in `index.astro`. This change ensures build-time image optimizations (e.g. correct sizing and webp conversion) are preserved. Additionally, index-based logic for `loading` and `fetchPriority` was added for superior LCP (Largest Contentful Paint) metrics.

Impact: Substantial payload reduction since images are optimized for web (e.g. webp format) and are the correct size (800x600 for grid view, 80x80 for list view). This improves load speed and performance metrics.

Co-authored-by: fysp11 <13081700+fysp11@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@kinsta

kinsta Bot commented Jul 29, 2026

Copy link
Copy Markdown

Preview deployments for fysp11.github.io ⚡️

Status Branch preview Commit preview
✅ Ready Visit preview Visit preview

Commit: 3fc587e7ab6b0955575b5f49144a46d9db8cea03

Deployment ID: e27a42de-e208-44b8-a3e5-521a45f6b80e

Static site name: fysp11githubio-cleb3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant