Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

How to build a one-page website that scores 90+ on Lighthouse

A small business site does not need a framework. Plain HTML and CSS can score 90+ on Lighthouse for performance, accessibility, best practices and SEO with a few habits. This is the checklist I follow when I build one-pa

A small business site does not need a framework. Plain HTML and CSS can score 90+ on Lighthouse for performance, accessibility, best practices and SEO with a few habits. This is the checklist I follow when I build one-page sites.

1. Start with a minimal, valid skeleton

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Clear, specific page title (50-60 characters)</title>
  <meta name="description" content="One sentence that says what you offer and where.">
  <link rel="canonical" href="https://example.com/">
</head>

The language attribute, viewport, title and description fix several accessibility and SEO audits at once.

2. Keep it light

  • One CSS file or an inline <style> for a single page. No CSS framework.
  • No JavaScript unless something needs it. A contact link or a form action usually does not.
  • System font stack instead of web fonts: font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif.
  • Target under 100 KB total for the first load.

3. Images done right

<img src="team.webp" alt="Two staff in the shop" width="800" height="500" loading="lazy">
  • Use WebP or AVIF, sized to how large they display.
  • Always set width and height so the layout does not jump (this lowers Cumulative Layout Shift).
  • Write real alt text; use alt="" for purely decorative images.
  • Do not lazy-load the main hero image above the fold.

4. Accessibility basics that Lighthouse checks

  • Text contrast of at least 4.5:1 against its background.
  • One <h1>, then headings in order.
  • Links and buttons with visible text and a visible focus outline (never remove :focus-visible styling without a replacement).
  • Tap targets of about 44 px on mobile.
  • Form fields with a <label for="...">.

5. Support dark mode without extra work

:root { --bg:#fff; --ink:#14181f; }
@media (prefers-color-scheme: dark) { :root { --bg:#0e1116; --ink:#e6eaf0; } }
body { background:var(--bg); color:var(--ink); }

6. Add security headers

Best-practices scores and real safety both improve with headers like Content-Security-Policy, X-Content-Type-Options and Referrer-Policy. On Netlify, put them in a _headers file. I wrote a short guide to the seven I use here: https://dev.to/yogeshwarantechtools/a-10-minute-http-security-headers-checklist-for-small-websites-5aj

7. Test and iterate

Run Lighthouse in Chrome DevTools (incognito, mobile mode). Fix the biggest red item first, then re-run. Test on a real phone as well: scores do not show touch problems.

Quick checklist

  1. Valid skeleton with lang, viewport, title, description.
  2. No framework, almost no JavaScript, under 100 KB.
  3. Sized, modern-format images with alt text.
  4. Contrast, headings, labels and focus styles checked.
  5. Security headers set.
  6. Lighthouse run on mobile.

I keep a few small browser-only tools for this kind of work (JSON, Base64, URL; the full set adds hashes and regex): https://luxury-malabi-8a7447.netlify.app/toolbox.html

Written by Yogeshwaran Tech Tools. Corrections welcome.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.