Ryan Kegerreis

Should You Be Using A Single Page Application (SPA)?

March 01, 2020

What Is An SPA?

SPA’s have been gaining popularity over the past few years. With the rise of several JavaScript frameworks and libraries such as React, Vue, and Angular, it may finally be the age of the SPA. Sounds relaxing.

To dive in, let’s first address what an SPA is. SPA stands for Single Page Application, but that may not mean exactly what you think it means. SPA’s do not necessarily have to have only one navigable page, but instead are loaded and treated by the browser as one single page. Even if there are several different views that the user can interact with. This is done when the browser is getting information from a single HTML file and updating only the changes when a user wishes to visit a different view.

Benefits of an SPA

All that being said, why would you use an SPA to create your web app or site? After all its harder to learn new stuff than just making it traditionally. Well here are a few reasons you may want to consider getting into SPA’s.

Performance: In a SPA the entire web page is downloaded when the user first visits the site. This makes it feel much faster to transition between different views.

Less Server Interaction: SPA’s don’t need to work as much with the server in most use cases. When the whole web page is downloaded the only interaction with the server is the data the user is sending and receiving. The rest of the processes are sourced to the client machine.

User Experience: The user experience of an SPA is usually better than a server side website for a few reasons, but the most important one is speed. Since the entire website is downloaded when a user visits the site initially it feels much faster to switch between pages that don’t require data transfer. They’re already on your computer!

Detriments of an SPA

The advantages above are very tangible, but using an SPA still comes with some disadvantages that are worth knowing about.

Search Engine Indexing: This is a problem that is being addressed, but still exists today. SPA’s use AJAX (Asynchronous JavaScript XML). Search engines like Google and Bing have had some issues crawling AJAX sites properly, and some of that still exists today. Because of the indexing and search positions may not be as accurate as a traditional HTML site.

Memory Leaks: Since the single page is open for so long (the whole time the user is on the site), there is a greater chance of a memory leak occurring. Causing the page to not release memory that it no longer needs realistically.

It Requires JavaScript: Sometimes for various reasons users will disable JavaScript. This is bad news for SPA’s, and they will not function as intended.

Are They Right For You?

As we’ve seen SPA’s are an exciting technology that are far from perfect. So this comes down to the question, should you use one?

While there are pros and cons, overwhelmingly the answer is yes… if you need it. For many sites it doesn’t make sense to change everything over from a traditional HTML site to an SPA. But for some, particularly those with web apps that are intended to replace desktop programs, there are huge benefits to switching to an SPA.


Written by Ryan Matthew Kegerreis.