⚡ Bolt: Pre-calculate optimized image urls using getImage() in Astro file - #153
⚡ Bolt: Pre-calculate optimized image urls using getImage() in Astro file#153fysp11 wants to merge 1 commit into
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Preview deployments for fysp11.github.io ⚡️
Commit: Deployment ID: Static site name: |
💡 What: We are pre-optimizing image URLs on the server (in the
.astrofile) viaimport.meta.globandgetImage(). These URLs are passed into theProjectsView.tsxcomponent which now uses standard HTML<img>tags featuring appropriate performance attributes (loading="lazy"for below the fold elements,loading="eager"andfetchPriority="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"vsloading="lazy"tags.PR created automatically by Jules for task 16601872876506742483 started by @fysp11