User Image

Technology

The Web’s Next Transition

By Kent C. Dodds ||

 10 mins ||

 1 May, 2024

The web is made up of technologies that got their start over 25 years ago. HTTP, HTML, CSS, and JS were all first standardized in the mid-nineties (when I was 8 years old). Since then, the web evolved into a ubiquitous application platform. As the web has evolved, so too has the architecture for the development of these applications. There are many core architectures for building applications for the web these days. The most popular architecture employed by web developers today is the Single Page App (SPA), but we are transitioning to a new and improved architecture for building web applications.

The <a> and <form> elements have been around from the very beginning. Links for a browser to get things from a server, and forms for a browser to send things to a server (and get things in return). With this two-way communication established as a part of the specification from the start, it has been possible to create powerful applications on the web forever.

Here are the major architectures (in chronological order of popular use):

  1. Multi-Page Apps (MPAs)
  2. Progressively Enhanced Multi-Page Apps (PEMPAs, aka “JavaScript Sprinkles”)
  3. Single Page Apps (SPAs)
  4. The next transition

Each architecture of web development has benefits and pain points. Eventually, the pain points became enough of a problem to motivate the move to the next architecture which came with its own trade-offs.

No matter how we build our applications, we’re almost always going to need code running on a server (notable exceptions includes games like Wordle which [used to] store game state in local storage). One of the things that distinguishes these architectures is where the code lives. Let’s explore each of these in turn and watch how the location of code changed over time. As we cover each architecture, we’ll consider specifically the following use cases of code:

  • Persistence - saving and reading data from a database
  • Routing - directing traffic based on the URL
  • Data fetching - retrieving data from persistence
  • Data mutation - changing data in persistence
  • Rendering logic - displaying data to the user
  • UI Feedback - responding to user interaction

There are, naturally, more parts of a web application than these bits, but these are the bits that move around the most and where we spend the bulk of our time as web devs. Depending on project scale and team structure we may work in all of these categories of code or we may work on only a part of one.

Multi-Page Apps (MPAs)

In the early days, this is the only architecture that worked at all on the web based on the capabilities of web browsers at the time.

image

With Multi-Page Apps, all of the code we write lives on the server. The UI Feedback code on the client is handled by the user’s browser.

MPA Architectural Behaviors

image

Document Request: When the user enters a URL in the address bar, the browser sends a request to our server. Our routing logic will call a function to fetch data which communicates with the persistence code to retrieve the data. This data then gets used by the rendering logic to determine the HTML which will be sent as a response to the client. All the while, the browser is giving the user feedback with some kind of pending state (normally in the favicon position).

image

Mutation Request: When the user submits a form, the browser serializes the form into a request sent to our server. Our routing logic will call a function to mutate the data which communicates with the persistence code to make database updates. Then it will respond with a redirect so the browser triggers a GET request to get fresh UI (which will trigger the same thing that happened when the user entered the URL to begin with). Again, the browser will give the user feedback with pending UI.

Note: It’s important that successful mutations send a redirect response rather than just the new HTML. Otherwise you’ll have the POST request in your history stack and hitting the back button will trigger the POST request again (ever wonder why apps sometimes say “DON’T HIT THE BACK BUTTON!!” Yeah, that’s why. They should’ve responded with a redirect).

MPA Pros and cons

The mental model of MPAs is simple. We didn’t appreciate it back then. While there was some state and complicated flows handled primarily by cookies in the requests, for the most part everything happened within the time of a request/response cycle.

Where this architecture falls short:

  1. Full-page refreshes - Makes some things hard (focus management), other things impractical (imagine a full-page refresh every time we liked a tweet…), and some things just impossible (animated page transitions).
  2. UI Feedback control - It’s nice that the favicon turns into a spinner, but often a better UX is feedback that is visually closer to the UI the user interacted with. And it’s certainly something designers like to customize for branding purposes. And what about optimistic UI?

It’s notable that the web platform is constantly improving with the upcoming page transitions API which makes MPAs a more viable option for more use cases. But for the majority of web applications, that’s still not enough. In any case, at the time this problem was far from the minds of standards committees and our users wanted more now!

Progressively Enhanced Multi-Page Apps (PEMPAs)

Progressive Enhancement is the idea that our web applications should be functional and accessible to all web browsers and then leverage whatever extra capabilities the browser has to enhance the experience. The term was coined in 2003 by Nick Finck and Steve Champeon. Speaking of the capabilities of the browser…

XMLHttpRequest was initially developed by Microsoft’s Outlook Web Access team in 1998 but it wasn’t standardized until 2016 (can you believe that!?). Of course that never stopped browser vendors and web devs before. AJAX was popularized as a term in 2005 and a lot of people started making HTTP requests in the browser. Businesses were built on the idea that we don’t have to go back to the server for any more than little bits of data to update the UI in place. With that, we could build Progressively Enhanced Multi-Page Apps:\

image

Tags:

Client


Featured Post

Author Image

Tech SIM Swap Attacks: Analysis and Protective Mea...

Tech SIM Swap Attacks: Analysis and Protective Measures...

20 June, 2024
10 mins

Recent Post

User Image

Computer science has a racism problem: these resea...

Black and Hispanic people face huge hurdles at technology companies an...

User Image

How to Generate Astonishing Animations with ChatGP...

How to Generate Astonishing Animations with ChatGPT

User Image

The Web’s Next Transition

The web is made up of technologies that got their start over 25 years ...

Author

Fundamentals of React Hooks

Hooks have been really gaining a lot of popularity from the first day ...

Author Image

Tech SIM Swap Attacks: Analysis and Protective Mea...

Tech SIM Swap Attacks: Analysis and Protective Measures

User Image

14 amazing macOS tips & tricks to power up your pr...

The mysteriOS Mac-hines keep having more hidden features the more you ...

User Image

4 Easy Steps to Structure Highly Unstructured Big ...

4 Easy Steps to Structure Highly Unstructured Big Data, via Automated ...

User Image

14 amazing macOS tips & tricks to power up your pr...

The mysteriOS Mac-hines keep having more hidden features the more you ...

User Image

Top 20 mobile apps which nobody knows about…

In the vast ocean of mobile applications, some remarkable gems often g...

User Image

10 Hottest New Apps for You to Get Ahead in Septem...

Here we are again, in a tribute to the amazing stream of ideas that pr...

User Image

How much does mobile app development cost

The cost of developing a mobile application can vary depending on seve...

User Image

React Native App Development Guide

DWIN, founded in 2015, has swiftly established itself as a leader in c...

User Image

Comparison of Top 6 Python NLP Libraries

Comparison of Top 6 Python NLP Libraries

User Image

Type Checking with TypeScript in React Native Navi...

📱 In the realm of mobile app development with React Native, ensuring ...

User Image

Guide to Set Up Push Notifications in React Native...

1. Create a New React Native Project (if not already created)

User Image

React 19 new features

React version 19 introduces a slew of groundbreaking features aimed at...