Skip to content

perf(images): replace raw <img> with next/image across the site - #49

Merged
Son7c merged 1 commit into
GDGCampusAEC:mainfrom
Furox-Art:perf/next-image-conversion
Oct 12, 2026
Merged

Son7c merged 1 commit into
GDGCampusAEC:mainfrom
Furox-Art:perf/next-image-conversion

Conversation

@Furox-Art

Copy link
Copy Markdown
Contributor

Closes #40

What

Replaced every raw <img> element with the framework's optimized image
component (next/image). All 26 occurrences across 11 files were
converted; only the framer-motion motion.img in the lightbox is left
as-is (it is animation-driven with dynamic sizing, see "Left
intentionally" below).

How each category was handled

  • Local static assets (/balloon.svg, /gdsc-logo.png,
    /cloud-white-3.svg, /gallery-1.gif, team photo, ...): given
    explicit width/height from the real file dimensions (measured with
    ImageMagick), which lets the browser reserve space and eliminates CLS.
  • Remote images on already-allowed domains (ik.imagekit.io,
    i.ytimg.com): fill + sizes so they render responsive and get
    automatic WebP/AVIF conversion.
  • GitHub avatars (avatars.githubusercontent.com): switched from the
    legacy github.com/<user>.png URL to the proper avatar endpoint and
    added the domain to next.config.ts remotePatterns.
  • Third-party / dynamic sources (Unsplash event images, PokeAPI
    sprites, admin thumbnails, courses): unoptimized so the optimizer is
    bypassed for hosts not in the allowlist — the component is still used
    (lazy loading + responsive behavior preserved), the build does not
    require new allowlist entries.

What this fixes

Raw <img> bypasses automatic format conversion (WebP/AVIF), responsive
resizing, and lazy loading, which causes Cumulative Layout Shift on
slower connections. next/image addresses all three.

Tests performed

  • npx tsc --noEmit -p tsconfig.json — passes with zero errors.
  • next build — compiles successfully (the TypeScript stage passes);
    the only build failure is a pre-existing ImageKit publicKey env
    requirement unrelated to this change (it fails on main too without
    .env).
  • Verified with grep that 0 raw <img> elements remain and 30 <Image>
    components + 11 next/image imports are in place.

Left intentionally

  • motion.img in CinematicLightbox.tsx — animated by framer-motion
    with max-h-[60vh] object-contain dynamic sizing; converting it would
    change the lightbox's animation behavior. Better left for a dedicated
    change.

All 26 <img> occurrences converted to next/image:
- local assets get explicit width/height (measured) to prevent CLS
- allowed remote hosts (imagekit, ytimg) use fill + sizes
- GitHub avatars moved to avatars.githubusercontent.com (domain added
  to remotePatterns)
- third-party/dynamic sources use unoptimized (no allowlist changes)

Raw <img> bypasses WebP/AVIF conversion, responsive resizing and lazy
loading. tsc --noEmit passes with zero errors. Closes #40
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

@Furox-Art is attempting to deploy a commit to the GDG On Campus AEC's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Son7c
Son7c merged commit aeb86e5 into GDGCampusAEC:main Oct 12, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PERFORMANCE] Eliminate unoptimized native image tags

2 participants