Lab 14: Progressive Enhancement

Time: 30 minutes | Level: Advanced | Docker: docker run -it --rm node:20-alpine sh

Overview

Master progressive enhancement and graceful degradation: @supports feature detection, CSS fallback stacks, Baseline 2024 features, polyfill strategies with type=module/nomodule, and the PE vs graceful degradation philosophy.


Step 1: Progressive Enhancement vs Graceful Degradation

Progressive Enhancement (PE):
─────────────────────────────────────
Start: Basic functionality works everywhere
Then: Enhance for capable browsers
Philosophy: "Works for all, better for modern"

Graceful Degradation (GD):
─────────────────────────────────────
Start: Build for modern browsers
Then: Add fallbacks for older browsers
Philosophy: "Best for modern, acceptable for old"

The difference in practice:
  PE: Start with <form>, enhance with JS validation
  GD: Build JS validation, fall back to server-side

Modern recommendation: Progressive Enhancement
  — Users on slow connections get core functionality
  — Screen reader users get accessible baseline
  — Future browsers don't break unexpectedly

Step 2: @supports Feature Detection


Step 3: @supports selector()


Step 4: CSS Fallback Value Stacks


Step 5: Baseline 2024 Features


Step 6: JavaScript Module/NoModule Pattern


Step 7: Polyfill Strategies


Step 8: Capstone — @supports Compatibility Checker

(Create the file:)

📸 Verified Output:


Summary

Technique
Syntax
Purpose

@supports

@supports (display: grid) {}

Feature detection

@supports not

@supports not (display: grid)

Absence detection

@supports selector()

@supports selector(:has(a))

Selector support

Value fallback

Multiple property values

Browser-specific

Module/nomodule

type="module" / nomodule

JS differential serving

Dynamic polyfill

import('polyfill').then(...)

Conditional loading

Baseline check

Baseline 2024 status

Ship decision

PE principle

Base → Enhanced

Future-proof

Last updated