Skip to content

perf(ui): optimize application images with next/image#1546

Open
ArshVermaGit wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
ArshVermaGit:main_5
Open

perf(ui): optimize application images with next/image#1546
ArshVermaGit wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
ArshVermaGit:main_5

Conversation

@ArshVermaGit
Copy link
Copy Markdown

Description

This PR addresses the major frontend performance enhancement by migrating the extensive use of standard HTML <img> tags to Next.js's native, optimized <Image> component.

This change tackles frontend performance bottlenecks by enabling automatic WebP/AVIF compression, lazy loading out of the box, and enforcing explicit sizing to completely eliminate layout shifts as components render.

Resolved Issue

Resolves #1545

Changes Made

  • Config Updates: Added github.githubassets.com to remotePatterns in next.config.mjs to allow optimized achievement badges to be served.
  • Component Refactoring: Integrated next/image into:
    • src/components/BadgeSection.tsx
    • src/components/GitHubAchievements.tsx
    • src/components/FriendComparison.tsx
    • src/components/WrappedExperience.tsx
    • src/components/landing/LandingPage.tsx
  • Page Refactoring: Integrated next/image into:
    • src/app/leaderboard/page.tsx
    • src/app/compare/[users]/page.tsx
  • Exclusions: StatsCard.tsx and opengraph-image.tsx were intentionally left using <img> to prevent breaking the html-to-image and @vercel/og libraries which require raw DOM images.

Motivation and Context

Previously, large grids of contributor avatars, achievement badges, and OG preview cards were causing layout jumps (CLS) and heavily degrading the Largest Contentful Paint (LCP) times because the images were unoptimized original JPEGs/PNGs. This PR resolves those performance penalties.

Testing Instructions

  1. Pull down the branch and start the development server (npm run dev).
  2. Navigate to the /leaderboard and /compare routes and verify that user avatars load correctly without any layout snapping.
  3. Check the dashboard's "GitHub Achievements" section to ensure the badges are successfully loading from github.githubassets.com.
  4. Run npm run build to ensure there are no unoptimized image warnings during the build step.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@ArshVermaGit is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels May 29, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown
Author

@ArshVermaGit ArshVermaGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Priyanshu-byte-coder ! Issue #1545 has been resolved. Please review the PR and merge it under GSSoC. Thanks!

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

Labels

gssoc26 GSSoC 2026 contribution type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Optimize Images using Next.js <Image> Component for Performance

1 participant