Lab 13: Performance Optimization
Overview
Step 1: Critical CSS (Above-the-Fold Inline)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Page</title>
<!-- 1. Inline critical CSS (no network request) -->
<style>
/* Only what's needed for above-the-fold content */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; }
.hero { min-height: 100svh; display: flex; align-items: center; justify-content: center; }
.nav { position: sticky; top: 0; z-index: 100; background: white; }
h1 { font-size: clamp(2rem, 5vw, 4rem); }
</style>
<!-- 2. Non-critical CSS: async load -->
<link rel="preload" href="/css/main.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="/css/main.css"></noscript>
<!-- 3. Resource hints (see Step 2) -->
</head>Step 2: Resource Hints
Step 3: async vs defer Scripts
Step 4: Core Web Vitals
Step 5: content-visibility
Step 6: loading=lazy and Image Optimization
Step 7: CSS Performance Patterns
Step 8: Capstone — CSS Minifier
Summary
Technique
Implementation
Metric Impact
Last updated
