Single-page applications (SPAs) are everywhere. I believe at this point most developers have played with them, or at least have a rough guess of what they try to solve. The concept became very popular in the past few years and has been applied in both small and considerably big (Facebook, Twitter, Netflix) applications.

The idea is to load a full page from the server just once. Once the first page is loaded, the application responds to the user interaction by dynamically updating the content of the current page without requiring entire new pages from the server. As a result, you have a web application that behaves as a typical desktop app. Only the necessary content will change and the users don't need to wait for a full page reload every time they click on a link or submit a form.

Before you decide whether or not you should go for the SPA approach, you need to understand the positive and negative aspects of it. You can find some more detailed coverage for that here, while our post will focus on the following pros and cons:

Pros

Faster responses: Regardless of the browser cache, the application doesn't reload all of the resources like CSS and JavaScript files, images and fonts every time a new request is made. It will be done just once, then only business data will be passed back and forth. Basically, less content to load leads to faster user interaction feedback.

Regardless of the browser cache, the application doesn't reload all of the resources like CSS and JavaScript files, images and fonts every time a new request is made. It will be done just once, then only business data will be passed back and forth. Basically, less content to load leads to faster user interaction feedback. Better user experience: SPAs are focused on reducing UI response delays. That allows users to perform more actions in less time, resulting in a more seamless experience.

Cons

First page load: As said before, most of the resources are loaded in the first page, which can give an initial impression of slowness when compared to a more traditional web page. Also, the content is usually loaded asynchronously, which can result in some unexpected behavior.

As said before, most of the resources are loaded in the first page, which can give an initial impression of slowness when compared to a more traditional web page. Also, the content is usually loaded asynchronously, which can result in some unexpected behavior. Added complexity on the client: To develop a SPA you will probably need a client-side framework, adding complexity to your project. Also, instead of one full-stack app you'll need to create two separate applications, which can increase development time.

Delivering a faster application that offers a better user experience is in itself enough reason to give SPA a try, but it’s important to make a careful estimation of time and resources necessary to apply it in your project, to minimize the odds that you regret on this decision later on.

What if you're in a small team with a tight schedule and still want to build an application that works like a SPA? Is it possible to achieve similar results without the complexity added by a front-end framework?

The answer is yes and this post will present you with an alternative to achieve that.