The Problem With Single Page Applications
April 4th, 2017
Single Page Applications have become the newest craze sweeping the web. Frameworks such as Angular and ReactJS are hugely popular and driving this current trend. However, besides the cool factor, are SPAs really a good design choice for most websites?
What is a SPA?
A traditional website, such as this one, requires refreshing pages during navigation - each new page pulls content from either the server or the browser cache (for example, clicking "next page"). In contrast, A Single Page Application is a webpage that loads the HTML, CSS and Javascript once, and afterwards the content within the page is modified as needed using asynchronous Javascript calls. Usually this relies on separate microservices responsible for handling those requests. The advantage to an SPA is a more interactive user experience, but the trade-off is a lot of extra code and complexity over a traditional website.
Single Page Applications are not a new concept - Using Ajax requests to asynchronously modify elements of a web page dates back more than a decade and a half, and if used appropriately can vastly enhance a user's website experience. An SPA is essentially an extension of that idea, making the entire website function similarly to a desktop application. In some cases, this is a very good idea (for example, Google Docs). By blurring the line between a desktop and web application, it now becomes possible to move some some of these applications into the web, which has many advantages - but some significant disadvantages as well.
What's wrong with SPAs?
My point here isn't that SPAs are bad - on the contrary, there are plenty of well designed SPAs that are brilliant in their implementation. The problem is, as is so often the case, the misuse of this technology. SPAs have a very narrow range of usable applications, but due to the recent explosion of frameworks many websites are built as an SPA when they should not be. I largely attribute this problem to the current design trends, and eager developers with a solution looking for a problem.
The vast majority of typical websites should not be built as an SPA. To that end, I certainly hope that no website design firm chooses to build a company website using an SPA (I say that tongue-in-cheek, because I know there are).