| 1 |
--- |
| 2 |
title: "Another Real World React -> htmx Port" |
| 3 |
description: "In this article, Carson Gross summarizes a real-world case study of Adrian McPhee porting the OpenUnited platform from React to htmx, documenting significant reductions in code complexity and development time while highlighting how content-focused web applications can benefit from a hypermedia architectural approach." |
| 4 |
created: 2023-09-20 |
| 5 |
modified: 2023-09-20 |
| 6 |
authors: ["Carson Gross"] |
| 7 |
tags: ["case-studies"] |
| 8 |
--- |
| 9 |
|
| 10 |
import { Image } from 'astro:assets'; |
| 11 |
import openUnitedBeforeAfter from '../../assets/img/open-united-before-after-htmx.png'; |
| 12 |
|
| 13 |
The [Mother of All htmx Demos](/essays/a-real-world-react-to-htmx-port) you can see the real world results of a |
| 14 |
port from a React-based front end to an htmx-powered front end. The results are very good, although we qualify the |
| 15 |
experience with the following: |
| 16 |
|
| 17 |
> These are eye-popping numbers, and they reflect the fact that the Contexte application is extremely amenable to |
| 18 |
> hypermedia: it is a content-focused application that shows lots of text and images. We would not expect every |
| 19 |
> web application to see these sorts of numbers. |
| 20 |
> |
| 21 |
> However, we _would_ expect _many_ applications to see dramatic improvements by adopting the hypermedia/htmx approach, |
| 22 |
> at |
| 23 |
> least for part of their system. |
| 24 |
|
| 25 |
As luck would have it, we have another application (again, based on Django on the server side) that has been ported from |
| 26 |
a React front end to an htmx front end: [OpenUnited](https://openunited.com/). |
| 27 |
|
| 28 |
Here is a graphic from |
| 29 |
the [original LinkedIn post](https://www.linkedin.com/feed/update/urn:li:activity:7109116330770878464/) |
| 30 |
by Adrian McPhee, showing the total Lines of Code in the code base before and after the port: |
| 31 |
|
| 32 |
<Image src={openUnitedBeforeAfter} alt="Open United before and after htmx port comparison" /> |
| 33 |
|
| 34 |
### Before/After Source Code |
| 35 |
|
| 36 |
A very nice aspect of this port is that, because OpenUnited is open source, in contrast with Contexte, the before and |
| 37 |
after code is available to examine: |
| 38 |
|
| 39 |
Before: https://github.com/OpenUnited/old-codebase |
| 40 |
|
| 41 |
After: https://github.com/OpenUnited/platform |
| 42 |
|
| 43 |
## Executive Summary |
| 44 |
|
| 45 |
Here is a high-level summary of the port |
| 46 |
|
| 47 |
* They reduced the **code base size** by **61%** (31237 LOC to 12044 LOC) |
| 48 |
* They reduced the **total number of files** by **72%** (588 files to 163 files) |
| 49 |
* They reduced the **total number of file types** by **38%** (18 file types to 11 file types) |
| 50 |
* Subjectively, development velocity felt at least **5X** faster |
| 51 |
* Rather than prototyping in Figma and then porting to HTML, UX development was done directly in HTML |
| 52 |
|
| 53 |
## Analysis |
| 54 |
|
| 55 |
Once again we have some eye-popping results. This is because the OpenUnited application is extremely |
| 56 |
amenable to hypermedia: like Contexte, it is a content-focused application that shows lots of text and images. |
| 57 |
|
| 58 |
This experience again demonstrates that, for at least a certain class of web applications, htmx and the hypermedia |
| 59 |
architecture can be an excellent choice. |