Returning to the Hypermedia System: Replacing JavaScript with HTML
The modern web development landscape has been dominated by complex client-side frameworks that treat the browser as an application runtime rather than a document viewer. However, a growing movement is advocating for a return to the web's original intent: a hypermedia system. By prioritizing HTML over JavaScript, developers can reduce complexity, improve initial load times, and align with the the architectural patterns that have made the web scalable for decades.
The Case for HTML-First Development
At its core, the web is a hypermedia system. When we move away from heavy JavaScript bundles and return to server-side rendering (SSR) and native HTML transitions, we rediscover the "blazing fast" performance and simplicity that often gets lost in the noise of modern SPAs (Single Page Applications).
Using a backend—such as Go, as noted by community members—to serve pre-rendered HTML allows the browser to do what it does best: parse and render documents. This approach removes the need for complex state synchronization between the client and the server, as the server remains the single source of truth.
Balancing Simplicity and Performance
While the shift toward HTML-first development is compelling, it is not without its trade-offs. The primary tension lies between the simplicity of the server-driven approach and the optimized user experience of client-side interactivity.
The Network Roundtrip Problem
One of the primary criticisms of the HTML-first approach is the increased reliance on network requests. In a traditional SPA, a small piece of JavaScript can update a local state variable to change a UI element's size or visibility without hitting the server. In a strict HTML-driven model, changing a view state may require a full page reload or a fragment update from the server.
As one developer pointed out:
"With the change, I now need another roundtrip network request to get new sizes of the same content on the current page that would have been able to be done in just a couple hundred bytes of JavaScript."
Alternative Middle-Grounds
To mitigate these issues, the browser platform is evolving. Developers are exploring hybrid approaches that maintain the simplicity of HTML while providing the fluidity of JS-driven apps. These include:
- CSS Variables: Using JavaScript solely to toggle a CSS variable that controls layout or size, avoiding a full server roundtrip while maintaining a clean separation of concerns.
- Web Components: Leveraging native browser components to encapsulate behavior without needing a heavy framework.
- View Transitions API: The use of CSS transitions and the View Transitions API helps bridge the gap, making server-side navigation feel as seamless as a client-side transition, though browser support (particularly in Firefox) remains a limiting factor.
The Future of the Hypermedia System
The web platform is evolving to become a more robust hypermedia system. Beyond simple HTML, proposals for general transclusion and other architectural improvements are being developed to allow the web to be more more expressive without relying on the "JS-everything" paradigm.
Ultimately, the goal is not to eliminate JavaScript entirely, but to find the right tool for the right job. By treating HTML as the primary driver of the application state and using JavaScript as a progressive enhancement, developers can create applications that are more accessible, resilient, and significantly easier to maintain.