Building a fast, accessible website
By Kallistesoft · · 3 min read
A fast, accessible website comes mostly from good early choices. After ten years of shipping sites and apps, this one included (plain static HTML), I keep seeing the same mistakes: too much JavaScript, oversized images, weak contrast, keyboards forgotten.
Static HTML or a framework?
For a marketing site or a blog, static HTML is hard to beat: the browser gets a finished page instead of waiting for a script to build it. Our site is deployed by GitHub Actions to ordinary hosting with almost nothing to maintain. A framework earns its place when interface state gets complex (dashboards, dynamic forms). Even then, generate content ahead of time and keep JavaScript for the interactive parts. The classic trap is picking a framework out of habit for a ten-page site, then spending hours fixing a performance score that plain HTML would have given you for free.
Core Web Vitals
Google publishes "good" thresholds for three metrics (web.dev):
| Metric | Measures | Threshold | Main lever |
|---|---|---|---|
| LCP | Render time of the largest element | 2.5 s | Serve the hero image early, small CSS |
| INP | Responsiveness to interactions | 200 ms | Less JavaScript, fewer third-party widgets |
| CLS | Layout shifts | 0.1 | Declared image sizes, reserved space |
For LCP, never put loading="lazy" on the hero image. For CLS, always declare dimensions:
<img src="/img/workspace-800.webp" width="800" height="450"
alt="Desk with two monitors">
Images, fonts and caching
- Images: WebP or AVIF for photos, SVG for logos and icons. Never a 4000 px image in a 400 px slot: use
srcset. - Fonts: one family,
font-display: swap, or just a system font stack, the fastest option. - Caching: versioned files (
style.css?v=20261108) can be cached for a long time, HTML gets revalidated (MDN). Turn on gzip or Brotli.
Cache-Control: public, max-age=31536000, immutable # versioned files
Cache-Control: no-cache # HTML pages
Accessibility basics
Use semantic HTML: header, nav, main, a single h1, headings in order, <button> for buttons and <a href> for links. A <div onclick> is neither focusable nor announced by screen readers. Declare lang and label every field.
WCAG asks for at least 4.5:1 contrast on normal text (criterion 1.4.3). Light grey on white is the usual offender; recheck both themes if you offer dark mode. Alt text describes the image's purpose in one sentence; a decorative image gets alt="". For keyboards, never remove the focus outline without replacing it:
:focus-visible { outline: 3px solid #2f6bff; outline-offset: 2px; }
How to test
- Lighthouse (Chrome DevTools), in mobile mode: trust trends, not a single score.
- axe: catches contrast, missing labels and invalid ARIA, but only part of the problems.
- Keyboard only: Tab, Shift+Tab, Enter, Space. Can you do everything while seeing where you are?
- Screen reader: ten minutes with VoiceOver or TalkBack on your key pages.
Checklist
- One h1,
langdeclared, headings in order. - Modern images, with dimensions and
alt. - Long cache on versioned files, compression on.
- 4.5:1 contrast, visible focus, everything usable by keyboard.
Conclusion
Performance and accessibility come from the same habits: less code, correct HTML, reasonable images. Run the checklist on your most visited page, measure, then repeat.
Sources
- Web Vitals — web.dev
- Largest Contentful Paint — web.dev
- Cumulative Layout Shift — web.dev
- HTTP caching — MDN
- Contrast (Minimum) — W3C WAI