Traditionally, developers will go with a multi-page application, but lately, single page applications, or SPAs, have taken the development world by storm. Google, Facebook, and Trello all use SPAs which are dynamically updated to respond to customer requests during use. The idea behind the SPA is that the user will only modify the content with which he interacts, removing the need for extra pages in order to access essential functionality.
What are the benefits of the SPA?
An SPA can come with many benefits, starting with increased performance and higher conversion rates. With SPAs, due to their dynamic architecture, the server does not have to reload all the HTML, CSS and script resources with every interaction. When the user requests new data through an interaction with the app, the app will only download this data from the servers, while the general framework of the app remains in place. This leads to a lighter server payload.
On top of that, with an SPA, you do not have to rebuild the entire backend if you already have a web app. All you have to do is rebuild the front-end. For multiple-page apps, this is not the case. This means that you can also rewrite the entire front-end of the SPA as many times as necessary, without having to touch the back-end of the app.
What are the drawbacks of the SPA?
There are some areas in which multi-page apps outperform SPAs. To start, SPAs are not very good for SEO because you can only add a certain number of keywords on a single page. As such, SEO for the SPA has to be very focused on the best matches for user requests. This is one of the workarounds for this drawback. Search engines give priority to domains that are devoted to a single theme. If you can keep your content focused, your app should perform well on search engines.
SPAs also suffer from memory leaks, due to the use of event listeners. These listeners will await a notification for any action performed by the user. However, events can be unbound incorrectly when the HTML content is modified. This means that the event listener remains in the memory of the device, even though it is no longer related to any of the content on the page. Unless this is handled within the code, memory mismanagement can occur.
You will also encounter problems with scalability. By definition an SPA is not very scalable – it has to remain on a single page. And while you try to respect this restriction when adding new features to the app, you run the risk of increasing load times.
When choosing between single-page and multi-page apps you have to take into consideration numerous factors, such as your business end goals, various use cases, expected UI/UX, and the benefits that will be delivered to the user base. If you have a single product or single service company, you will be best served by SPAs. For larger businesses and more diversified use cases, the multi-page app is the way to go.