Skip to main content
Saved

The Progressive Enhancement Mindset

foundation
10 minute read
written by
den odell
added

With progressive enhancement, your web app keeps working for everyone, even when some of its code fails to load.

bundle sizeA 500KB JavaScript bundle can cost someone real money and take minutes to load.

TL;DR

With progressive enhancement, you build web apps from the ground up. You start with HTML that works everywhere, then add CSS on top to make it look right, and then add JavaScript to make it nicer to use.

  • You build in layers, with HTML first, then CSS, and then JavaScript
  • The layers above the HTML are optional, so the page doesn’t depend on them loading
  • If one layer breaks, the layers below it keep working
  • Your site stays usable and fast for everyone, whatever their browser or network

A journey of a thousand miles begins with a single step.

Lao Tzu, Tao Te Ching

Defining Progressive Enhancement

With progressive enhancement, you build the parts of your site that every user needs first, and then add enhancements on top.

You start with HTML, so every user gets the content and core functionality, whatever browser or network they’re using. CSS goes on top to improve how it looks, and then JavaScript adds richer interactive features in browsers that can run it.

Each layer improves on the one below it, and the page still works if the layers above it don't.

Browsers and networks vary a lot, so you’re designing for the slow and unreliable ones as well as the fast ones.

If JavaScript fails to load, the CSS still makes your site presentable. Your users might lose some features, but they can still do what they came to do. If CSS doesn’t load, the HTML still delivers all the content.

In a JavaScript-first application, nothing renders unless the scripts run successfully. With progressive enhancement, each user gets the best experience their browser and network can support.

The Case for Progressive Enhancement

JavaScript fails to run more often than you might realize, for lots of different reasons:

  • Networks drop packets
  • CDNs go down
  • Corporate proxies block scripts
  • Browser extensions conflict with scripts
  • Ad blockers strip out content
  • Mobile connections time out

And one uncaught error stops the rest of that script from running, which can include everything your page needs.

If your site needs JavaScript just to display content, any of these failures means your users see nothing.

Failures like these happen all the time on the web, and progressive enhancement is a way of building sites that keep working when they do.

Progressive enhancement has other benefits too:

  • Semantic HTML makes your site more accessible
  • With less code, your site loads faster
  • Keeping the layers separate makes your code easier to maintain

Instead of starting with “what features can I build?”, you start by asking “what does every user need to be able to do?”

The Layers of Enhancement

Building a site in layers is like building a house. The foundation and walls go up before any smart home features, so if the automation breaks, you still have a house to live in.

  1. HTML Foundation

    The HTML gives the page its structure and basic functionality, so forms submit and links navigate. It works in every browser.

    Core capabilities

    • Semantic structure
    • Content delivery
    • Form submission
    • Navigation
  2. CSS Presentation

    CSS adds typography, layout, color, and spacing without breaking any functionality. If it fails to load, the HTML still delivers the content.

    Core capabilities

    • Layout and grid
    • Typography
    • Responsive design
    • Visual hierarchy
  3. JavaScript Enhancement

    JavaScript adds interactivity and richer behavior, such as real-time updates and validation, and the page still works without it.

    Core capabilities

    • Real-time updates
    • Client validation
    • Transitions
    • Rich interactions

You only build one version. The HTML works without the other two layers, CSS makes it look better, and JavaScript makes it easier to use.

Graceful Degradation vs Progressive Enhancement

Graceful Degradation

You build the full-featured version first and then add fallbacks, so you’re designing for the best case and working backward.

The mindset: “We’ll build this amazing experience, and if JavaScript is disabled, here’s a fallback.”

The baseline ends up as an afterthought.

Progressive Enhancement

You build the baseline version first and then add features for browsers that support them, so you’re designing for the worst case and working upward.

The mindset: “We’ll make sure this works everywhere first, then make it amazing for capable browsers.”

The baseline is the foundation that everything else is built on.

When you start with the baseline, it’s working and tested before you add anything on top of it.

Graceful Degradation takes a deeper look at how that principle relates to progressive enhancement.

Misconceptions About Progressive Enhancement

A few common myths put teams off adopting progressive enhancement (PE), and you’ve probably heard some of them.

Myth: “PE means building everything three times”

Reality: You only build it once, with HTML for structure, CSS for styling, and JavaScript for enhancement, all in the same component.

Myth: “PE means no JavaScript”

Reality: With PE, JavaScript is an enhancement, so you can use as much of it as you like, as long as your core functionality doesn’t depend on it.

Myth: “PE is only about users with JS disabled”

Reality: Network failures, loading errors, script blockers, and performance issues can all stop JS from running, and any of your users might run into them.

Myth: “PE makes development slower”

Reality: Your architecture often ends up simpler with PE, because semantic HTML is easier to test and maintain, and when the layers are kept separate, you spend less time debugging.

Myth: “Modern frameworks can’t do PE”

Reality: Modern frameworks like Next.js, Nuxt, SvelteKit, and React Router, which Remix has now merged into, support PE through server-side rendering.

Myth: “PE means ugly, basic websites”

Reality: Plenty of polished, well-designed websites use PE, including GitHub and GOV.UK.

A navigation menu starts as an HTML list of links, then CSS positions and styles it, and JavaScript improves the interactions. If the JavaScript or CSS fails, the layers below them keep working.

Thinking About the Layers Inside Components

These days, a lot of frontend developers think in components. A dropdown menu becomes a React component and a modal becomes a Vue component, and it’s easy to lose sight of the fact that each of them is built from layers.

It helps to think about what each layer of the component does instead.

Your HTML should make sense by itself, with semantic elements and a proper document structure that don’t rely on JavaScript to generate them.

Your CSS should work without JavaScript, so the layout and styling apply to the HTML as it arrives from the server, without expecting JavaScript to change the DOM first.

Your JavaScript should add useful behavior that the page doesn’t depend on. You might intercept form submissions to give users a better experience, and the forms should still submit normally if JavaScript fails. You might add smooth transitions to navigation, and the links should still work as standard links.

If one layer fails, your site still works. Without CSS, your content is unstyled but usable, and without JavaScript, it’s styled but doesn’t have the enhanced interactions.

The practical guide Building with Progressive Enhancement goes into how to implement this.

The Reliability Spectrum

HTML, CSS, and JavaScript aren’t equally reliable in the browser, and that’s why the layers go in this order.

HTML: Bulletproof

HTML has been part of the web since 1991, and over more than three decades browsers have become very forgiving of errors in it.

CSS: Resilient

Browsers skip over any CSS properties they don’t support, so when something goes wrong, it usually only affects how the page looks, and the page still works.

JavaScript: Fragile

JavaScript is the most fragile layer, because a script has to download completely before it runs, and a single syntax error stops the whole file from running.

You add the layers in order of how reliable they are:

  1. HTML is the most reliable, so it’s the foundation
  2. CSS is fairly reliable, so it goes on top of the HTML
  3. JavaScript is the least reliable, so it goes on last

JavaScript can fail in the most ways, and when it fails, it does the most damage. With JavaScript as the top layer, a script failure in your app doesn’t break the core functionality underneath it.

Building for the Whole World

Progressive enhancement also helps your site work for people on any network, and for people with disabilities.

In many countries, mobile data is expensive and networks are slow. A 500KB JavaScript bundle can cost someone real money and take minutes to load. If you start with HTML, they can read your content as soon as it arrives.

For users with disabilities, semantic HTML gives assistive technologies such as screen readers and voice navigation the structure they rely on. They work much less well with pages that JavaScript builds out of generic div elements.

With progressive enhancement, accessibility is part of your site from the start. If your baseline experience is semantic HTML, you’ve already met a good part of the WCAG requirements.

Feature Detection Over Assumptions

With progressive enhancement, you check what a browser can do instead of assuming it.

If you assume every user has JavaScript enabled, or that every browser supports a particular API, your site can break for anyone whose browser doesn’t match that assumption. In practice, some browsers don’t support newer APIs, and scripts don’t always run, either because the user disabled JavaScript or because the connection dropped before the scripts loaded.

With feature detection, you test whether a browser supports a feature before you use it. You check whether the feature exists instead of checking which browser or version someone uses, so when a browser adds support later, your code starts using the feature without any changes.

You also need a fallback for when a feature is missing, so the page does something simpler instead of breaking, and users still get the same core functionality.

The Feature Detection pattern covers the implementation details.

Defense in Depth

Progressive enhancement uses the same idea as defense in depth, the security principle where you build several layers of protection, so that when one fails, the others still work.

In a web application, your critical functionality should work at more than one level. A form should still work through a traditional POST submission if your fetch request fails, and navigation should still work through standard HTML links if your JavaScript router breaks.

Each layer is built to keep working when the layers above it fail, without duplicating code across the layers.

Your HTML form works without JavaScript, and your JavaScript intercepts the submission so users get a better experience whenever the script runs.

For an e-commerce site, the critical paths are browsing products, adding to the cart, checking out, and paying, because the site can’t do its job without them. Each of those steps should work at the HTML level first, with enhancements added on top.

The Defense in Depth principle goes into this in more detail, and the Error Boundary Pattern shows it applied.

PE in Practice

A form and a navigation menu both show the three layers working together.

Example 1: Form Submission

The form starts as HTML that works without JavaScript. CSS then adds visual feedback, and JavaScript submits the form in the background.

Layer 1: HTML Foundation

<form action="/api/contact" method="POST">
  <label for="email">Email</label>
  <input type="email" id="email" name="email" required />
  <button type="submit">Send</button>
</form>

This works everywhere because the browser handles validation and submission natively.

Layer 2: CSS Enhancement

form {
  display: grid;
  gap: 1rem;
  max-width: 400px;
}

input:invalid {
  border-color: red;
}

input:valid {
  border-color: green;
}

button {
  padding: 0.75rem;
  background: blue;
  color: white;
}

The CSS adds visual feedback without breaking the HTML underneath it.

Layer 3: JavaScript Enhancement

const form = document.querySelector('form');
const button = form.querySelector('button');

form.addEventListener('submit', async (e) => {
  e.preventDefault();

  const data = new FormData(e.target);

  // Show loading state
  button.disabled = true;

  try {
    const res = await fetch(form.action, {
      method: 'POST',
      body: data
    });
    if (!res.ok) throw new Error(`Request failed: ${res.status}`);

    // Show the success message
  } catch {
    // If the background request fails, fall back to a normal form submission
    form.submit();
  }
});

With this script, the form submits in the background and your users get instant feedback, and if the script doesn’t load, the HTML form still works.

Example 2: Navigation

The navigation starts as standard links, then gets client-side routing so pages change without a full reload.

Layer 1: HTML Foundation

<nav>
  <a href="/">Home</a>
  <a href="/about">About</a>
  <a href="/contact">Contact</a>
</nav>

These standard links work in all browsers and support keyboard navigation out of the box.

Layer 2: CSS Enhancement

nav {
  display: flex;
  gap: 2rem;
}

a {
  padding: 0.5rem 1rem;
  text-decoration: none;
  transition: all 0.2s;
}

a:hover {
  background: blue;
  color: white;
}

a[aria-current="page"] {
  font-weight: bold;
}

The CSS adds hover styles and marks the current page, and the links still work the same way.

Layer 3: JavaScript Enhancement

// Client-side routing
const nav = document.querySelector('nav');

nav.addEventListener('click', async (e) => {
  const link = e.target.closest('a');

  // Let the browser handle external links and clicks that open a new tab or window
  const isModifiedClick = e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
  if (link && link.origin === location.origin && !isModifiedClick) {
    e.preventDefault();

    const url = link.href;

    // Fetch & update
    const res = await fetch(url);
    const html = await res.text();

    // Update DOM (updatePage is your own function that swaps in the new content)
    updatePage(html);

    // Update history
    history.pushState({}, '', url);
  }
});

This changes pages without a full reload in browsers that run the script, and standard navigation still works if JavaScript fails.

Modern Frameworks and Progressive Enhancement

You might assume modern JavaScript frameworks like React, Vue, or Svelte are incompatible with progressive enhancement, but you can build progressively enhanced applications with them.

With server-side rendering, your framework renders HTML on the server and sends it to the browser, so the page is visible as soon as it arrives, and that’s your first layer. Then JavaScript loads and “hydrates” the page, adding interactivity. If JavaScript fails, the server-rendered content still displays.

MPA vs SPA: A False Choice

The Reality

You don’t have to choose between multi-page applications (MPAs) and single-page applications (SPAs). Most real applications are somewhere in the middle.

A typical app has server-rendered pages with JavaScript-enhanced interactions, where some sections behave like SPAs and others use traditional navigation. You can mix and match based on what each part of your app needs.

Server Rendering by Default

Meta-frameworks like Next.js, Nuxt, SvelteKit, and React Router, which used to be Remix, render pages on the server by default, so it’s easier to build an app this way.

Whichever tools you use, your server should deliver meaningful content, and JavaScript should add to that content instead of replacing it.

Building with Progressive Enhancement shows how to implement this with modern frameworks.

PE and Application Architecture

Progressive enhancement also changes how you structure your application.

Routing

Without PE: Routing only happens on the client, with JavaScript handling all navigation, so nothing works if JS fails.

With PE: Each route is rendered on the server and returns full HTML, and the client-side router adds smooth transitions on top.

State Management

Without PE: Client-side state is the source of truth, so all your app state is kept in JavaScript and lost on reload.

With PE: The URL and the server state are the source of truth, and client state adds to them, such as remembering which panel is open.

Data Fetching

Without PE: With fetch on mount, the component mounts, shows a loader, and then fetches data, so the HTML is empty until JS runs.

With PE: With server-side rendering, data is fetched on the server and rendered to HTML, then the client hydrates the page for interactivity.

Form Handling

Without PE: Forms only work through JavaScript, because the JS handlers disable native submission entirely.

With PE: HTML forms submit to server endpoints, and JavaScript adds client-side validation and optimistic UI on top.

Next.js, Nuxt, React Router, SvelteKit, and Astro all make progressively enhanced apps easier to build.

Most of them offer:

  • Server-side rendering by default
  • Automatic code splitting and lazy loading
  • Form actions that work without JavaScript
  • Streaming and progressive hydration

The Performance Philosophy

Progressively enhanced applications also tend to be faster, because when you build from a working baseline and add enhancements on top, you end up deferring code that the page doesn’t need right away. Your critical rendering path only needs to include the HTML and critical CSS, because your basic functionality doesn’t need JavaScript.

As a result, first contentful paint happens sooner, and links and forms work before JavaScript has finished loading. The site also feels faster, because users see content while JavaScript is still downloading in the background.

Each framework and library you add increases your bundle size and the time the browser spends running scripts. With progressive enhancement, you have to justify each one you add. A large framework is hard to justify for static content that HTML and CSS can display with a little selective enhancement.

Progressive enhancement helps you work out which code the page really needs, so you can load the rest later or leave it out.

The Testing Mindset

Progressive enhancement changes how you test, because you need to check that your site works when some of the layers fail, as well as in ideal conditions.

Testing Strategies

Layer Testing

With JavaScript disabled in your browser’s developer tools, you can load your site and try navigating and submitting forms. If the page is blank or broken, it isn’t progressively enhanced.

Testing across browsers and devices helps too, because Chrome features might not work in Safari or Firefox, and interactions built for a mouse might not work from a keyboard or touchscreen.

Network Testing

If you throttle the network to 3G speeds, you can see what happens when your scripts time out, and how your site behaves on real-world connections.

These tests check for resilience, so they look at whether your core functionality works whatever the conditions, and whether the enhancements can fail without breaking everything.

There’s more on this in Building with Progressive Enhancement.

Embracing Uncertainty

Part of progressive enhancement is accepting that the web is unpredictable. You can’t control how good your users’ network connection is, or whether browser extensions interfere with your code.

You can control how your application responds, though, by building it to adapt to what’s available and fail gracefully when something is missing.

If you ask “what happens when this fails?” as well as “will this work?”, you end up building for the slow networks and broken scripts your users really run into.

The Web’s Fault Tolerance

The web was designed to cope with failures, and each part of it handles errors in its own way:

  • HTTP reports failed requests with status codes, so the client can deal with them
  • Browsers ignore CSS they don’t support
  • HTML parsers recover from errors in the markup

Your code can work the same way.

Your Response Strategy

With progressive enhancement, your code should handle problems like this:

  • If a script or request fails, the page falls back to a simpler version
  • If a browser doesn’t support a feature, your code falls back to something simpler
  • On a slow network, content appears as it arrives

The Path Forward

Sites built with progressive enhancement are more resilient, so they work for more people in more situations, and they also tend to be faster and more accessible.

It takes practice, because you have to get used to thinking about each component in layers, and to thinking about how things can fail before you think about how they work.

You start with HTML that delivers core functionality and make sure it works. Then you add CSS to match your design, check that the styled HTML still works, and add JavaScript to enhance the experience.

Four Simple Steps

  1. You start with HTML that works everywhere
  2. You add CSS on top to make it look right
  3. You add JavaScript on top of that to make it nicer to use
  4. You test each layer as you add it

Each layer builds on the ones below it, and none of them depend on the layers above working.

Related Content:

External Resources:

Next Foundation · 12 min read

Accessibility as a Foundation

Accessibility belongs in your architecture from day one, instead of being retrofitted later.

Read the next Foundation →

Keep Exploring

A monthly email
from Den Odell.

What I'm thinking about frontend patterns, plus news when the site changes.

No spam. Unsubscribe anytime.