I recently had the opportunity to present at the 2024 DjangoCon US in Durham, NC, and I’m eager to share my insights. My session was titled “Choosing Wisely: SPA vs. HTMX for Your Next Web Project,” and it built upon my previous talk on enhancing Django web apps with HTMX, AlpineJS, and streaming HTML.
One question that arose often was: when should teams choose a Single-Page Application (SPA) versus a Hypermedia-driven solution? While SPAs are popular, they come with inherent weaknesses that can hinder user experience. Specifically, the process of downloading, parsing, and executing custom JavaScript applications before retrieving data can create frustrating delays for users.
Prominent figures like the large consultancy ThoughtWorks and Alex Russell, who helped create the SPA pattern and the browsers we use every day, have raised concerns about the over-reliance on SPAs, emphasizing the need for better performance metrics during the development phase. Moreover, maintaining a stellar user experience with SPAs is more challenging than teams expect, between every feature having the ability to slow down every other feature and the complexity of replacing native browser features—especially now that browsers ship with excellent support for new CSS functionality.
Any system that puts JavaScript in the critical path starts at a disadvantage because JS costs three times more processing power, byte for byte, than HTML and CSS and removes the browser’s ability to optimize page loading.
Be sure to check out the success stories of teams who transitioned from SPAs to the hypermedia approach, achieving significant reductions in code complexity and remarkable boosts in developer productivity—resulting in an exceptional user experience.
As we move forward, we must rethink our reliance on established practices. Let’s challenge the notion that SPAs are always the best choice and embrace innovative solutions that prioritize user satisfaction.
I’d love to hear your thoughts on this topic. If you’re interested, check out the full video of my presentation for deeper insights!