Commit f97751f
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
---1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
0 commit comments