Stop using JavaScript for that
summary
Browsers now implement common UI patterns so less JavaScript is needed: actual recipes include building toggles with a checkbox plus appearance: none and :checked, autosuggest via datalist, color pickers with input type=color, smooth fragment navigation via scroll-behavior: smooth plus scroll-margin-top and :target highlighting, sticky headers with position:sticky, carousels with scroll-snap, lazy images with loading=lazy, downloads with the download attribute, accordions with <details>/<summary>, and modals using <dialog> with showModal (dialog needs a tiny bit of JS for invocation). Polypane runs many experimental features.
AI-written summary · about
chapters (12)
- 0:00Introduction and rule of least power
- 3:57Custom toggles with CSS
- 12:15Built-in form features
- 16:15Native smooth scrolling
- 20:12Scroll margin and target highlights
- 23:06Sticky positioning
- 25:19Scroll snapping for carousels
- 28:52Lazy loading and PDF downloads
- 30:21Native accordions with details
- 33:13Dialog elements for modals
- 37:52Upcoming CSS features preview
- 45:24Future of browser-native development
