Core Web Vitals Nedir?
Core Web Vitals, Google'ın 2026'da sıralama faktörü olarak kullandığı üç temel performans metriğidir:
- LCP (Largest Contentful Paint): En büyük içerik öğesinin yüklenme süresi. Hedef: <2.5 saniye
- INP (Interaction to Next Paint): Etkileşim yanıt süresi. Hedef: <200ms
- CLS (Cumulative Layout Shift): Görsel stabilite. Hedef: <0.1
1. PHP ile PageSpeed API Sorgulama
function get_pagespeed_score($url, $api_key) {
$endpoint = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?'
. http_build_query([
'url' => $url,
'key' => $api_key,
'strategy' => 'mobile',
'category' => 'performance',
]);
$data = json_decode(
file_get_contents($endpoint), true
);
return [
'score' => $data['lighthouseResult']['categories']['performance']['score'] * 100,
'lcp' => $data['lighthouseResult']['audits']['largest-contentful-paint']['numericValue'],
'cls' => $data['lighthouseResult']['audits']['cumulative-layout-shift']['numericValue'],
];
}
2. Resim Optimizasyonu
function optimize_image($source, $dest, $quality = 80) {
$info = getimagesize($source);
switch ($info['mime']) {
case 'image/jpeg':
$img = imagecreatefromjpeg($source);
imagejpeg($img, $dest, $quality);
break;
case 'image/png':
$img = imagecreatefrompng($source);
imagepng($img, $dest, 9);
break;
case 'image/webp':
$img = imagecreatefromwebp($source);
imagewebp($img, $dest, $quality);
break;
}
imagedestroy($img);
}
3. Lazy Loading ve Kritik CSS
<!-- Resimlerde Lazy Loading -->
<img src="placeholder.svg"
data-src="resim.webp"
loading="lazy"
width="800" height="600"
alt="Açıklama">
<!-- Kritik CSS Inline -->
<style>
.hero{min-height:400px;background:#1e293b}
.nav{display:flex;align-items:center}
</style>
<!-- Geri kalan CSS async yükle -->
<link rel="preload" href="style.css" as="style"
onload="this.onload=null;this.rel='stylesheet'">