Skip to content

perf: lazy-load country flag images to reduce initial page load (#128) - #132

Merged
smrithipiedy merged 1 commit into
smrithipiedy:mainfrom
Mohammad-Hassan027:feat/lazy-load-flags
Jul 7, 2026
Merged

perf: lazy-load country flag images to reduce initial page load (#128)#132
smrithipiedy merged 1 commit into
smrithipiedy:mainfrom
Mohammad-Hassan027:feat/lazy-load-flags

Conversation

@Mohammad-Hassan027

Copy link
Copy Markdown
Contributor

Description

Resolves #128.

Country flag <Image> components were using the unoptimized prop, a legacy
workaround from the Cloud Run deployment. This prop bypasses Next.js image
optimisation and also disables its built-in lazy loading, causing all flag images
to load eagerly — even those far below the fold — on initial page load.

With the Vercel migration, this workaround is no longer needed.

Changes Made

  • src/app/choose-path/page.tsx: Removed unoptimized from the selected-country
    flag <Image>. Next.js <Image> defaults to lazy, so no extra attribute needed.
  • src/components/Location/CountrySelector.tsx: Removed unoptimized and added
    explicit loading="lazy" to country list flag images — the primary source of
    unnecessary network requests on initial load.

Performance Impact

  • Flags below the fold are no longer fetched on page load
  • All flag images are now processed through Next.js image optimisation (resizing,
    format conversion, CDN caching)
  • Reduces initial network requests and improves LCP

Testing

  • Verified flag images still render correctly in the country selector
  • Confirmed lazy loading behaviour using browser DevTools (Network tab)
  • No TypeScript or build errors

…thipiedy#128)

- Remove legacy `unoptimized` prop from flag `<Image>` components
- Re-enables Next.js default image optimization and lazy loading behavior
- Add explicit `loading="lazy"` to CountrySelector list images
- Fixes eager loading of below-the-fold flag images, reducing initial LCP
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

@Mohammad-Hassan027 is attempting to deploy a commit to the Smrithi P's projects Team on Vercel.

A member of the Team first needs to authorize it.

@smrithipiedy smrithipiedy added enhancement New feature or request SSoC26 A contribution through Social Summer Of Code Easy Easy Issue labels Jul 7, 2026
@smrithipiedy
smrithipiedy merged commit c960b0f into smrithipiedy:main Jul 7, 2026
3 of 4 checks passed
@Mohammad-Hassan027
Mohammad-Hassan027 deleted the feat/lazy-load-flags branch July 7, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Easy Easy Issue enhancement New feature or request SSoC26 A contribution through Social Summer Of Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Lazy-load country flag images to improve initial page load performance

2 participants