Case Study: איך הגענו ל-100 ב-Lighthouse - המדריך המלא
סיפור הצלחה מפורט: איך הגענו ל-100 ב-Lighthouse. כולל הבעיות שזיהינו, הפתרונות שיישמנו, והשיעורים שלמדנו.
6 דקות קריאהביצועים
במקרה הזה נספר לך סיפור הצלחה אמיתי: איך הגענו ל-100 ב-Lighthouse. נסביר מה היו הבעיות, איך פתרנו אותן, והשיעורים שלמדנו.
הרקע: הבעיה
האתר: אתר חברה בינונית, Next.js
הבעיה: ציון Lighthouse נמוך
הנתונים לפני:
- Performance: 45
- Accessibility: 78
- Best Practices: 82
- SEO: 85
- סה"כ ממוצע: 72.5
המטרה: להגיע ל-100 בכל הקטגוריות.
השלב הראשון: זיהוי הבעיות
1. Performance Audit
עשינו Audit מקיף:
הבעיות שזיהינו:
- ⚠️ LCP: 5.2 שניות (גרוע)
- ⚠️ FID: 250ms (גרוע)
- ⚠️ CLS: 0.35 (גרוע)
- ⚠️ Bundle Size: 2.5MB (גדול מדי)
- ⚠️ תמונות לא אופטימליות
2. Accessibility Audit
הבעיות:
- ⚠️ Alt text חסר
- ⚠️ Focus states לא ברורים
- ⚠️ Contrast ratios נמוכים
- ⚠️ ARIA labels חסרים
3. Best Practices Audit
הבעיות:
- ⚠️ Console errors
- ⚠️ HTTPS issues
- ⚠️ Deprecated APIs
4. SEO Audit
הבעיות:
- ⚠️ Meta tags חסרים
- ⚠️ Structured Data לא מלא
- ⚠️ Sitemap לא מעודכן
השלב השני: הפתרונות
1. Performance - מהירות
א. אופטימיזציה של תמונות
לפני:
<img src="/hero.jpg" alt="Hero" />
אחרי:
import Image from 'next/image';
<Image
src="/hero.jpg"
alt="Hero"
width={1200}
height={630}
priority
loading="eager"
/>
התוצאה:
- LCP: 5.2s → 1.8s (-65%)
- Image Size: 800KB → 120KB (-85%)
ב. Code Splitting
לפני:
import HeavyComponent from './HeavyComponent';
אחרי:
import dynamic from 'next/dynamic';
const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
loading: () => <p>טוען...</p>,
ssr: false
});
התוצאה:
- Initial Bundle: 2.5MB → 800KB (-68%)
ג. Font Optimization
לפני:
@import url('https://fonts.googleapis.com/css2?family=Heebo');
אחרי:
import { Heebo } from 'next/font/google';
const heebo = Heebo({
subsets: ['hebrew'],
weight: ['400', '600', '700'],
display: 'swap',
preload: true,
});
התוצאה:
- FOIT: נעלם
- CLS: 0.35 → 0.05 (-86%)
ד. ISR (Incremental Static Regeneration)
לפני:
// SSR - רץ על השרת כל פעם
export default async function Page() {
const data = await fetch('...');
return <div>{data}</div>;
}
אחרי:
export const revalidate = 3600;
export default async function Page() {
const data = await fetch('...');
return <div>{data}</div>;
}
התוצאה:
- TTFB: 800ms → 50ms (-94%)
2. Accessibility - נגישות
א. Alt Text
לפני:
<img src="/image.jpg" />
אחרי:
<Image
src="/image.jpg"
alt="תיאור מפורט של התמונה"
width={1200}
height={630}
/>
ב. Focus States
לפני:
button:focus {
outline: none; /* ❌ */
}
אחרי:
button:focus {
outline: 2px solid #FFFFFF;
outline-offset: 2px;
}
ג. ARIA Labels
לפני:
<button>X</button>
אחרי:
<button aria-label="סגור">X</button>
ד. Contrast Ratios
לפני:
.text {
color: #888888; /* Contrast: 2.5:1 - גרוע */
background: #000000;
}
אחרי:
.text {
color: #C9C9C9; /* Contrast: 8.5:1 - מעולה */
background: #0B0A08;
}
3. Best Practices
א. Console Errors
לפני:
console.error('Error:', error);
אחרי:
if (process.env.NODE_ENV === 'development') {
console.error('Error:', error);
}
ב. HTTPS
לפני:
- Mixed Content
- HTTP resources
אחרי:
- הכל על HTTPS
- Secure headers
ג. Deprecated APIs
לפני:
document.write('...'); // Deprecated
אחרי:
document.createElement('div'); // Modern
4. SEO
א. Metadata
לפני:
export default function Page() {
return <div>Content</div>;
}
אחרי:
export const metadata = {
title: 'כותרת',
description: 'תיאור',
openGraph: {
title: 'כותרת OG',
images: ['/og-image.jpg'],
},
};
export default function Page() {
return <div>Content</div>;
}
ב. Structured Data
לפני:
// אין Structured Data
אחרי:
const structuredData = {
"@context": "https://schema.org",
"@type": "WebPage",
"name": "כותרת",
};
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
/>
ג. Sitemap
לפני:
// אין Sitemap
אחרי:
// app/sitemap.ts
export default async function sitemap() {
return [
{
url: 'https://example.com',
lastModified: new Date(),
},
];
}
התוצאות: לפני ואחרי
Performance
| מדד | לפני | אחרי | שיפור |
|---|---|---|---|
| Performance Score | 45 | 100 | +122% |
| LCP | 5.2s | 1.2s | -77% |
| FID | 250ms | 50ms | -80% |
| CLS | 0.35 | 0.02 | -94% |
| Bundle Size | 2.5MB | 800KB | -68% |
Accessibility
| מדד | לפני | אחרי |
|---|---|---|
| Accessibility Score | 78 | 100 |
| Alt Text Coverage | 60% | 100% |
| Focus States | 40% | 100% |
| Contrast Ratios | 70% | 100% |
Best Practices
| מדד | לפני | אחרי |
|---|---|---|
| Best Practices Score | 82 | 100 |
| Console Errors | 15 | 0 |
| HTTPS Issues | 3 | 0 |
| Deprecated APIs | 2 | 0 |
SEO
| מדד | לפני | אחרי |
|---|---|---|
| SEO Score | 85 | 100 |
| Meta Tags | 60% | 100% |
| Structured Data | 0% | 100% |
| Sitemap | ❌ | ✅ |
השיעורים שלמדנו
1. מהירות = Priority #1
מהירות היא הכי חשובה:
- משפיעה על כל המדדים
- משפיעה על SEO
- משפיעה על המרות
2. Accessibility = לא אופציונלי
נגישות היא חובה:
- חוקית
- אתית
- עסקית (יותר משתמשים)
3. Best Practices = מניעת בעיות
Best Practices מונעים בעיות:
- פחות באגים
- יותר אמינות
- יותר אמון
4. SEO = תהליך מתמיד
SEO זה לא חד-פעמי:
- עדכון מתמיד
- מדידה מתמדת
- שיפורים
איך ליישם את זה?
1. התחל ב-Audit
- Lighthouse
- PageSpeed Insights
- WebPageTest
2. זהה בעיות
- Performance
- Accessibility
- Best Practices
- SEO
3. תעדף
- מה הכי חשוב?
- מה הכי קל לתקן?
- מה הכי משפיע?
4. יישם
- שלב אחר שלב
- מדוד תוצאות
- המשך לשפר
סיכום
הגענו ל-100 ב-Lighthouse בזכות:
- ✅ אופטימיזציה של תמונות
- ✅ Code Splitting
- ✅ Font Optimization
- ✅ ISR
- ✅ Accessibility מלא
- ✅ Best Practices
- ✅ SEO מלא
התוצאה:
- ✅ Performance: 100
- ✅ Accessibility: 100
- ✅ Best Practices: 100
- ✅ SEO: 100
ההשפעה:
- ✅ יותר תנועה
- ✅ יותר המרות
- ✅ יותר אמון
רוצה להגיע ל-100 ב-Lighthouse? צור קשר ונעזור לך.