Technical Deep Dives
Page Speed Optimization

Page Speed Optimization

Page speed is a critical ranking factor and directly impacts user experience. Faster pages have lower bounce rates, higher conversions, and better search rankings.

Why Page Speed Matters

53%
Bounce Rate

Mobile users leave if page takes >3 seconds

+7%
Conversions

Per 1 second improvement

Rankings

Google uses speed as a ranking factor

Core Web Vitals

Speed affects LCP and INP

Key Speed Metrics

Metric Good Needs Work Poor
Time to First Byte (TTFB) < 200ms 200-500ms > 500ms
First Contentful Paint (FCP) < 1.8s 1.8-3s > 3s
Largest Contentful Paint (LCP) < 2.5s 2.5-4s > 4s
Total Blocking Time (TBT) < 200ms 200-600ms > 600ms

Image Optimization

Images often account for the largest portion of page weight. Optimizing them can dramatically improve load times.

Format Selection
  • WebP - Best overall compression, wide support
  • AVIF - Even better compression, growing support
  • JPEG - Photos, fallback for older browsers
  • PNG - Transparency, graphics, logos
  • SVG - Icons, simple graphics, scales perfectly
Optimization Techniques
  • Compress - Reduce file size without visible quality loss
  • Resize - Serve appropriately sized images
  • Lazy load - Load images as they enter viewport
  • Responsive - Use srcset for different screen sizes

Lazy Loading

<!-- Native lazy loading -->
<img src="image.jpg" loading="lazy" alt="Description">

<!-- Responsive with lazy loading -->
<img srcset="small.jpg 480w,
             medium.jpg 800w,
             large.jpg 1200w"
     sizes="(max-width: 600px) 480px,
            (max-width: 1000px) 800px,
            1200px"
     src="medium.jpg"
     loading="lazy"
     alt="Description">

JavaScript Optimization

  • Minify - Remove whitespace and comments
  • Bundle - Combine files to reduce HTTP requests
  • Defer - Use defer or async for non-critical scripts
  • Code split - Load only what's needed for each page
  • Tree shake - Remove unused code during build

Script Loading Strategies

<!-- Blocks rendering - use sparingly -->
<script src="critical.js"></script>

<!-- Downloads in parallel, executes in order after parsing -->
<script src="script.js" defer></script>

<!-- Downloads in parallel, executes immediately when ready -->
<script src="analytics.js" async></script>

CSS Optimization

Critical CSS

Inline critical above-the-fold CSS directly in the HTML to render content faster. Load remaining CSS asynchronously.

Remove Unused CSS

Audit stylesheets and remove rules that aren't used. Tools like PurgeCSS can automate this.

Caching Strategies

Asset Type Recommended Cache Time
HTML pages No cache or short (for dynamic content)
CSS/JS (versioned) 1 year
Images 1 year
Fonts 1 year
API responses Varies (seconds to hours)

Server Optimization

Use a CDN

Serve static assets from geographically distributed servers to reduce latency.

Enable Compression

Use Gzip or Brotli compression for text-based resources (HTML, CSS, JS).

HTTP/2 or HTTP/3

Enable modern protocols for multiplexing and faster connections.

Speed Optimization Checklist

External Resources