Show HN: We built swup+fragment-plugin to visually enhance classic websites
## TL;DR

- Progressively enhance your classic website / MPA to a single page app.

- Support for fragment visits, comparable to nested routes in React or Vue.

- Keep your site crawlable and indexable without any of the overhead of SSR.

- No tight coupling of back- and frontend. Use the CMS / Framework / SSG of your choice.

- Strong focus on interoperability with DOM-altering JS tools (think Alpine.js, jQuery, ...).

- Strong focus on accessibility, even for fragment visits.

## Long Version: Best of three worlds

Hi, I'm Rasso Hilber. I have been a web designer and developer since around 2004. From the beginning of my career, I always had to make tradeoffs between 3 goals when building websites:

1. The websites I build should be visually impressive, original, and snappy.

2. The websites I build should be crawlable, accessible and standards compliant.

3. The websites I build should have low technical complexity and be easy to maintain in the long run.

In the beginning, I was able to achieve goals 1 (impressive!) and 3 (easy to maintain!) by using Macromedia/Adobe Flash, but due to the nature of the technology horribly failed to deliver crawlable and accessible websites. Later, I found a way to run two sites in parallel for each website I built, one using CMS-generated XHTML for crawlability, one in Flash for the visitors, fetching the data from its XHTML twin. Now I had solved goals 1 and 2, but my setup was awfully complex and brittle.

Around 2010, I was relieved to see Flash finally coming to its end. I switched to building websites using PHP, HTML, and jQuery. I could now tick goals 2 (accessibility) and 3 (low complexity), but the websites I was able to build using these technologies weren't as impressive anymore. Hard page loads between every link click being one of the biggest regressions in UX from the days of Flash IMO.

Around 2014/15, I first heard about the new frameworks: Angular, React, Vue. These frameworks were not intended to be used for classic websites. They were made for single-page-apps! But it felt to me like no one cared. Even when building classic websites, many developers sacrificed SEO and accessibility for a snappy experience, serving an empty `<div id="app"></div>` to the browser. I couldn't blame them; I had done the same in my early days as a Flash developer. They ticked goal 1 (impressive) and goal 3 (low complexity). But the lack of accessibility kept me from joining the movement. I was still building classic websites, after all.

After some time, many started realizing that serving an empty div had downsides – SSR, hydration, and whatnot were born, now ticking goal 1 (impressive) and goal 2 (accessibility), with the trade-off of awful complexity. It reminded me a lot of my little Frankenstein's monster "Flash+XHTML," and I still didn't want to join the hype.

Still, because the noise was so loud, I felt like I might be becoming obsolete, an "old man yelling at the clouds".

New very interesting tools like HTMX or Unpoly popped up that looked promising at first, but at closer inspection weren't optimized for my use case either. These were primarily built for real interfaces/single-page-apps (html snippets instead of full pages, UI state independent of URLs, altered DOM saved in history snapshots, ...). I wanted to find a tiny tool, optimized for building presentational, content-driven websites with a strong focus on accessibility.

Instead, after a few years of rolling my own home-grown solutions, I started using swup[0], a "Versatile and extensible page transition library for server-rendered websites". Swup consists of a tiny core and a rich ecosystem of official plugins[1] for additional functionality. It was hitting the sweet spot between simplicity and complexity, and felt like it was perfect for my use cases. Shortly after I had started using it, I became a core contributor and maintainer of swup.

The only thing I was still missing to be a happy developer was the ability to create really complex navigation paths where selected fragments are updated as you navigate a site, much like nested routes allow in React or Vue.

The last two months I teamed up with @daun [2] to finally solve this hard problem. The result is two things:

1. A new major release of swup (v4) that allows customizing the complete page transition process by providing a powerful hook system and a mutable visit object
2. The newly released fragment-plugin [3] that provides a declarative API for dynamically replacing containers based on rules

Use cases for the fragment-plugin are:

- a filter UI that live-updates its list of results on every interaction

- a detail overlay that shows on top of the currently open content

- a tab group that updates only itself when selecting one of the tabs

- a form that updates only itself upon submission

I can now finally build websites that tick all three boxes:

1. Visually impressive, fun, and snappy by using swup's first-class support for animations[4], cache[5], and preload capacities[6], enhanced with fragment visits as seen on the demo site.

2. Accessible by being able to serve server-rendered semantic markup that will fully work even with JavaScript disabled (try it out on the demo site!). On top of that, swup's a11y plugin[7] will automatically announce page visits to assistive technologies and will focus the new `<main>` element after each visit.

3. Because now all I need for my fancy frontend is a bit of progressive JavaScript, I can choose whatever tool I like on the server, keeping complexity low and maintainability high. I can use SSGs like eleventy or Astro (the demo site is built using Astro!), I can use any CMS like WordPress or ProcessWire, or a framework like Laravel. And I don't have to maintain an additional node server for SSG!

The plugin is still in it's early stages, but I have a good feeling that this finally is the right path for me as a web developer. All it took was 20 years! ;)

[0] https://github.com/swup/swup

[1] https://swup.js.org/plugins

[2] https://github.com/daun

[3] https://github.com/swup/fragment-plugin

[4] https://swup.js.org/getting-started/how-it-works/

[5] https://swup.js.org/api/cache/

[6] https://swup.js.org/plugins/preload-plugin/

[7] https://swup.js.org/plugins/a11y-plugin/