Skip to content

Commit f97751f

Browse files
authored
feat(frontend): optimize contributor avatar delivery (JhaSourav07#616)
## Description Fixes JhaSourav07#555 This PR improves contributor avatar rendering by introducing responsive image optimization and layout stability enhancements, addressing Lighthouse warnings related to oversized image delivery and cumulative layout shift. Previously, avatars were served at full resolution regardless of display size, leading to unnecessary payload overhead and suboptimal performance metrics on audit tools. ### Key Improvements * Responsive avatar sizing using GitHub’s `s` query parameter * Explicit `width` and `height` attributes to ensure layout stability (CLS prevention) * Lazy loading enabled for offscreen image deferral * Consistent square rendering using `aspect-square` * Maintains existing UI fidelity while improving performance efficiency ### Before ```jsx <img src={user.avatarUrl} alt={user.name} className="w-full h-full object-cover" /> ``` ### After ```jsx <img src={`${user.avatarUrl}${user.avatarUrl.includes('?') ? '&' : '?'}s=120`} alt={user.name || 'Contributor Avatar'} width={96} height={96} loading="lazy" className="w-full h-full aspect-square object-cover" /> ``` --- ## Impact * Eliminates oversized image delivery warnings in Lighthouse * Reduces unnecessary network payload for avatar assets * Improves visual stability via explicit intrinsic sizing * Enhances mobile performance and bandwidth efficiency * Aligns with modern frontend performance best practices --- ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) --- ## Visual Preview <img width="1038" height="740" alt="Screenshot 2026-05-27 154740" src="https://github.com/user-attachments/assets/0bb572b3-deb5-4ed3-8696-4d0631413516" /> Lighthouse comparison screenshots included demonstrating: * Reduced performance warnings * Improved layout stability (CLS) * Cleaner image optimization audit results --- ## Checklist before requesting a review * [x] I have read `CONTRIBUTING.md` * [x] I have validated changes locally * [x] I have run `npm run format` and `npm run lint` with no errors * [x] My commit follows Conventional Commits standards * [x] PR contains a single, atomic commit * [x] Changes maintain CommitPulse’s premium UI/UX standards ---
2 parents 1dea200 + c32c819 commit f97751f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

components/dashboard/ProfileCard.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export default function ProfileCard({ user, exportData }: ProfileCardProps) {
2727
<div className="relative mb-5">
2828
<div className="w-24 h-24 rounded-full overflow-hidden border border-black/10 dark:border-[rgba(255,255,255,0.12)]">
2929
{/* eslint-disable-next-line @next/next/no-img-element */}
30-
<img src={user.avatarUrl} alt={user.name} className="w-full h-full object-cover" />
30+
<img
31+
src={`${user.avatarUrl}${user.avatarUrl.includes('?') ? '&' : '?'}s=120`}
32+
alt={user.name || 'Contributor Avatar'}
33+
width={96}
34+
height={96}
35+
loading="lazy"
36+
className="w-full h-full aspect-square object-cover"
37+
/>
3138
</div>
3239
{user.isPro && (
3340
<span className="absolute -bottom-1 -right-1 text-[9px] font-bold bg-black text-white dark:bg-white dark:text-black px-1.5 py-0.5 rounded-full tracking-wide">

0 commit comments

Comments
 (0)