The Disadvantages of Single Page Applications (2014)
adamsilver.io
adamsilver.io
Once loaded it's probably one of the fastest website I've browsed, and it doesn't have any of the drawbacks you mentioned:
navigating to a new page is quick: ✓
navigating back is quick: ✓
remembering scroll position: ✓
cancelling navigation: ✗ but we won't allow duplicate requests so not an issue
SEO: ✓
Navigation and data loss: ? (no idea how we handle that tbh)
Navigation and loading CSS & JS: ✓ we load everything on the first load (~ 880kB) and that's it. I don't think it will ever be worst than MPA
Analytics: ✓
Automated functional testing: ✓ our unit + e2e test suites run in about 4 minutes (CI)
Our splash pages are open-sourced if you want to have a look at our setup: https://github.com/gocardless/splash-pages
Mobile aside, what is really gained in the SPA approach here when you have what is essentially a brochure site? That is, there isn't a lot of content, and it's all static AFAICT, so why not just send the minimal amount of html over the wire and be done with it? Html fragments are already covered for FAQ et al so don't even need to make a round trip to the server.
Anyway, you'd get above checkmarks for free and, if you generate server-side content using a type safe language (Scala, OCaml, Haskell, C#, etc.), for the most part you'd avoid the code salad of client-side typing.
Obviously I have a server-side bias, am curious to see real world use cases where SPAs are a must vs. a trend.
Not seeing any SPA requirement to click "Payment History" and js display a hidden layer.
Anyway, as far as SPA approaches go this site works well, pretty snappy, no FOUC, just pointing out that server-side + javascript for ajax/effects/transitions is also a viable means to creating a positive user experience.
But you're right our dashboards are also SPA.
* Support
* Guides
* Login
* Blog
are all outside the SPA, and some appear to be MPA apps. And perhaps once I logged in that would be its own new app as well?
So in that sense, your website in not an SPA, you have an app for getting new signups which is an SPA, and then you have a bunch of other SPA or MPA apps hooked up to that. As the author said, "Websites can still have Rich User Interfaces without cramming the entire site into one document."
I think the point is to find a balance and realize building your entire infrastructure into an SPA will indeed break the web and your user's experience, most likely. Having a mix of SPA/MPA apps that cover the various functionality you need, and using each where appropriate, is a much better use of resources and results in a better UX.
Agree, it's all about the user's experience for us, we use whatever tool we feel enable us to build the best UX (without breaking the web).
You can check the source code here: https://github.com/gocardless/splash-pages
Are you doing some escape fragment/headless browser for googlebots?
<div class="site-wrapper"
data-reactid=".20hl256vta8"
data-react-checksum="-1018283815">
http://facebook.github.io/react/docs/top-level-api.html#reac...Only ancient browsers fail to support the HTML5 History API. Currently, that is around 10% of the web. Your customers are likely to have a newer browser than IE 9 if they have a budget for technology at all.
http://caniuse.com/#feat=history
★ The problem with embracing the hash for navigation is that you are now committed to running JS on your root FOREVER to detect those URLs - or old bookmarks & links & social media posts will break ★
Source - https://gocardless.com/blog/how-we-built-the-new-gocardless....
May be this is why your site is so fast. SPA apps are not entirely static.
We generate all the HTML pages so that they can serve as entrypoints, so when you go to https://gocardless.com/features we serve a fully rendered page to the browser, plus we load the rest of the website (that's why it's super snappy after the initial page load).
If you don't have javascript enabled, you'll still get fully rendered page.
It is quite fast, which is nice. One of my concerns about SPAs that emulate MPWs is that you're sacrificing speed for complexity, which generally leads to errors. But by serving up static content and limiting interactivity, you get the speed while keeping complexity manageable.
I don't know how making a real single page app could be possible for overly complex applications. More than once I managed to crash the chrome javascript engine in a way that could not be recovered even when reloading the page and nothing short of a task manager kill could restore functionality
we are probably abusing too much canvas (we use fabric.js for image maniulation), but adding and removing the canvas from the dom should be safe enough, as we make sure not to store anything outside the dom itself specifically to avoid leaking resources
everything in memory is attached to data entries or in event handlers and browsers should be able to clean up them when the nodes are removed, except they dont.
The dashboard looks like a much better example of an SPA.
> customers in the UK and the Eurozone
Feel like this should be on the landing page though.I don't think the SPA juice is worth the squeeze.
But it's lovely to be able to open multiple compose windows in new tabs by just middle-clicking the "Compose Mail" link. Then again, I realise the more explicit workflow is a matter of preference (eg it won't autosave drafts unless you hit "Save draft", and I like that, but others might not).
Of course you're welcome to be as anti-SPA as you please. But those of us who've welcomed the concept with all the fervor of a relieved garrison generally have our reasons for so doing.
Why do they exist? User expectations of the web are increasing and waiting for server responses from any action isn't really cutting it anymore.
Of course it's harder to maintain state and develop - the patterns haven't been clearly defined, and SPAs introduce two sources of state (client and server) which is a hard problem. It's the cost of the demanded user experience.
Angular ui router, ember data, react flux architecture are all examples of things that have just started evolving to address these kinds of issues. All of these are very new and being constantly iterated on and updated. Angular ui router does a good job of handling things like the back button and managing the state of your page. Ember data has really powerful client side data state management, and react flux architecture presents a much needed practice of how to control the flow of data between server calls and views. HyperMedia APIs are another evolving technology for maintaining more control between the client and the server.
I realize that the "single page" in SPA refers to loading a single HTML page, but I've generally felt like SPAs work best when they're based around a primary view.
Once you start building a SPA that emulates a multi-page website, you're suddenly jumping through hoops that the browser/HTML previously gave you for free (routing, URL history, back button, etc.). If the main thing you'll get in return is faster page transitions, it's probably not worth it.
Is it an application?
Does it revolve around a single view that is not just a header toolbar?
Ok. You are now cleared for any other questions to evaluate SPAs. If the answer to either of those questions is no, just don't use a single page site.
As for answering the question of how much of a primary view makes the SPA worth it. If data needs to be retained within the view while making requests, then yes. Examples - spotify, most multi column apps, ERPs etc.
The amount of time saved in developing services and front-ends over a server-based system is so significant as to offset any of the complexities mentioned here.
The speed of development, the ability to rapidly change requirements, to adapt to stakeholders wants and needs...all are supported by the service+SPA model.
And tooling is coming in many forms to support this pattern, so it's not going anywhere.
It's not about where you execute your UI code, It's about how you structure your application.
I've seen plenty more of SPA's become an unmaintainable spaghetti nightmare and also seen many non-SPA's work splendidly.
I support parent comment and I can add: SPA split responsibilities between server side and frontend. It helps us to build services with APIs, reusable with different clients (mobile app can use same API with absolutely different UI), so this split looks like natural evolution. This article is just luddism.
I can give examples of a lot of things that SPA's can't do, that's not the point.
I also don't think, you should either build everything on the backend or everything on the frontend, I consider both approaches to be equally bad.
SPA's do not help split responsibilities, I can easily give the SPA a low level Data API and start implementing data processing functionalities in the frontend.
SPA's don't help build services, good frameworks do.
SPA is a religion, cause it states 'Single Page'. What if I want to have an application with 2 or 3 pages just because it doesn't make any sense whatsoever to cram everything into 1 page? What if I can render a lot of stuff on the backend and be 100x more efficient and provide far superior UX?
I had a colleague once who wanted to do everything on the client side, he said that the SPA is the way to go. He got 6 months to prove his approach is good. He failed. His application was both slow as hell and nobody on the team could maintain it. So after he left it took me roughly 2 months to implement what he had in 1/5th of the code.
Sure, if you have bad programmers, no pattern will save you. But if you want speed, agility, and separation of concerns, SPA + services is currently the way to go.
If you want speed, agility separations of concerns, MVC is the way to go. Most of the things you said are MVC and SRP, it has nothing to do with SPA, this is what I have been trying to explain. SPA stands for "Single Page Application", it doesn't specify anything beyond that, your code could be utter garbage with everything mangled together, and it's still technically a SPA. MVC on the other hand does specify how to organize your code.
I think the problem here is the SPA terminology itself and the way it's being used and marketed.
And it's not just Asana, there are some very popular web applications that have had to make the same decision in order to reduce the time it takes to load things for their users, especially users who aren't on fast links (mobile, rural, and places like South America, Africa and Australia).
SPA is a total b*tch to do user activity tracking and quirks and glitches just never end.
SPA rely on browser performance and users with slow connections or weak device - will wait much longer to see anything appearing on the page.
My advice - if you sell anything from your site - stay away from SPA.
We do mostly SPA's at our agency by now, and they're incredibly stable and easy to maintain. Each to his own, I guess.
What i'm surprised to see though, is that so few focus on improving the tech concept (SPA). I see so many complaints, but so few fixes. I don't think SPA is inherently bad, not by a long shot. It's just that, like any young idea it is far from perfect. But, that's technology! It's how advancement goes.
As technology goes, we tend to take two steps forward one step back. But it's often for the sake of _progress_. I have a Moto 360 on my wrist as i type this, but do i consider it amazing? God no, it has some nifty features sure, but it's massive and i can't even see what the time is without turning it on.
Take that in for a second - i have a watch and i have to turn my wrist and bring it up to my face to see the damn time. But do i think that it shouldn't exist? God no. When i got my first "smart" phone it was also awful. If i followed the (seeming) mantra of these negative people, i'd have been shouting for no smartphones phones and no smart watches for years before they had a really solid UX.
I understand a MPA currently offers a more reliable and overall better UX than SPAs tend to. However, can we please focus on improving this technology concept rather than screaming for them to not exist anymore? The HTML5 History API attempts to solve many of the complaints here. It also sounds like we should use data caching (in our SPAs) so that when a user hits back, they get a back-like experience. And as far as scroll position goes, that might be something the History API should provider (if it doesn't already).
Like it or not, JavaScript is here to stay. Usage of it will only increase. Rather than saying how terrible of a UX it has, please try to think in the reverse. Even if you aren't going to work on the solutions, this is the exact type of crowd that will. Cite your concerns and UX improvements - These are the sort of people you should be helping, to help you :)
/rant
The author of the post made his point pretty clearly:
> [T]he application handles the browsing instead of the browser. Attempting to mimic the browser using Javascript is the root cause of the self-induced issues.
I think you're conflating "single-page applications" with what the author called "rich user interfaces". They're two separate things. A single-page application is defined by the fact it does not let the remote server handle routing. I think you're conflating the two because otherwise your rant doesn't really make sense to me. You asked for fixes, and the blog post comes with one: let the server & the browser handle routing; don't re-invent the wheel (badly).
I think the general issue is that there are existing solutions that avoid the downsides associated with this approach, so this seems like re-inventing the wheel. Yes, needless negativity should be avoided, but so should breathless enthusiasm without due diligence.
I also find people touting "progress" don't realise that a lot of the time they just mean "change". I mean, sure, if a new way of doing things is demonstrably better, by all means let's use it. But a lot of the time you're just swapping one (well-understood) set of tradeoffs and considerations for a new, less understood set, because "That's what we're doing now".
For all that a lot of technical people like to make fun of the fashion industry, we definitely have our own as well.
(Not to take away from people trying different approaches. I'm all for trying alternate paths from 'best practice'. You don't want to get stuck on a local maximum. That said, there is a chunk of our industry that seems to congregate around whatever technology or approach has been recently discovered to be feasible)
Well, i sort of disagree. I agree that all progress isn't positive, but the problem is you can't really know that in the current timeframe. "progress" very often contains one (or more) steps back for every step forward. In the future, after the concept as matured, we will know if it is positive or not. But that is exactly how this works.
Sure, we can only use well tested, well understood, and well functioning concepts - but we already do that. What you are experiencing is bleeding edge, and we do not do bleeding edge where it really matters. Eg, good luck finding Nasa pulling this crap haha. In places where it is far less important, where you as a company/person have decided to use a product that is newer (probably for the sake of not being old, stale, and "safe"), then you have clearly chosen to accept the tradeoffs.
Again, in my experience, SPAs break the web 99% of the time. The times that they don't (e.g. Gmail), I still don't see what an SPA brings to the table that a simple MPA didn't. Yeah Gmail is nice, but it's no where near as good as a decent desktop or mobile mail app. And its miles away from a good, well structured MPA. SPAs just seem to sit in this no-mans land for me, and I'm not sure that more technology is the answer.
It's like Flash. When Flash came out I used to be a Flash developer for a while. But I had an epiphany as to why Flash development was so hard. It was the entire concept of the timeline, something that is at the core of Flash. A timeline is a sequence of keyed steps over time. The problem with this is that it make interactivity next to impossible; you were constantly fighting against the core purpose of Flash (play items in sequence over time). How do you handle users interrupting this sequence with their constant demands for interactivity? The answer was to throw the entire timeline concept out the window and generate all objects, items and stuff using code. That way you could handle arbritary interactions from the user. Well, I'm sure you can imagine how ridiculous that got over time. Frameworks and libraries and hacks and workarounds and generally just a big fat mess because Flash devs were constantly trying use Flash for something it was never designed to do in the first place.
For me, personally, SPAs and the related technology bear some of the similar hallmarks. Some developers want to use Web Browsers to write the equivalent of desktop apps. But browsers and the web in particular do not have the same interaction patterns as desktop apps (or mobile). But that is absolutely fine! The web is something else, it is its own thing.
But thats just me. By all means go for it! You are right that progress in technology is a good thing. I'm just wary of misdirected technological gains, like smart-jars, digital credit cards and smart smoke alarms that require internet connections.
To sum up; I wouldn't say it's negativity, it's more that some people are just not convinced by the concept at its core.
The author of this blog is someone I would befriend. It sounds like his work is probably non-cancerous to the eye.
While I've become rather cynical about web, it's telling that everyone is reading this and posting on a "primitive" and "laughable" site (to many web designers you DON'T want working for you), right now. I'd prefer to keep my 1995, primitive, laughable web in place. Maybe they can keep their blink tags.
Ruby's turbolinks is a clever hack and mostly works approach to make nav-based (browser history- and crawler SEO-compatible) almost as responsive as SPA... it replaces assets, title, meta and body on-the-fly and updates the url location with javascript to save a whole page update. It's basically a hybrid of client+server coordinated fragment caching. There are some gotchas and workarounds for onLoad() and other JS hooks, but it mostly works pretty well.
The whole history API exists to help the SPA experience (but others too).
The site still needs to be able to render something like:
www.foo.com/customers/10 even if www.foo.com is a SPA and via clicks can go to /customers/10. This may require more server work, so you're not exactly making life much easier for yourself.
You still need to handle cases where a web crawler comes in without good javascript and has to index your site.
I would assume that's one of the more capable crawlers though; not the average, and surely not the lower bound.
The aim isn't to "mimic the browser using Javascript" but to create an immersive application that feels like you're no longer in a browser at all.
Honorable mention for the application that you probably have in mind can go towards (IMO) React UI Builder which was posted to HN a few days ago (https://github.com/ipselon/react-ui-builder).
The only one I can think of that is successful is Google Maps. Though lately I seem have all sorts of problems navigating it, so maybe it's no longer a success.
"Feeling like you're no longer in a browser" isn't really a customer goal or a product goal. It could be a means to an end, depending on the application, but I don't see that many people executing it effectively.
The more common case by far seems to be people who want too much control, without realizing that they are actually degrading the experience (i.e. by messing up navigation, hyperlinks, copy-paste, accessibility, latency, etc.)
I always thought that the SPA crowd would settle on a custom content-type to handle web apps. That way they aren't hamstrung by the limitations of HTML and web pages and can really do things right by web apps.
That seems like a very odd goal.
I was developing clunky web applications with way too many text areas, buttons, tables, and pages pre-ajax. I'm much happier with the state of the web now.
Take "fast back" as an example. If your app is interactive and updates live, the "back" page can already be up and running with the latest data, instead of first loading a cached version and then having it update with JS later.
Also, personally I'm not so sure users care about things like the "stop" button working. And "fast back" depends on the situation.
Having said that: if these kinds of articles reduce the risk of things like blogger.com being a SPA, keep writing :)
A good example for a SPA would be something like a webmail client, a word processor, or a chat.
A bad example of it would be a blog, or a product website; these are much more suited for MPW
I'm conflicted wheteher these would benefit from a SPA or not: discussion boards, web shops and the like. I can see them benefiting from SPA, but I can also see some disadvantages. I guess they'd be more suited for a "hybrid solution" (MPW with some AJAX and/or WebSockets).
[1]: I work for a hosting company, so our clients are usually web developers (or sometimes they hire web developers).
I feel like a lot of the people making SPAs just haven't used a dodgy internet connection in five years or more.
Rule #1 of the web: Don't break the web
Having said that, you should also be supporting simply rendering the pages on the first request, and progressively enhance it, rather than a blank thing that then goes and fetches all the JS and render itself. The HTML/CSS should arrive and render as soon as possible. His reference to twitter's 2012 writeup is good.
Having said that, take a look at this:
http://platform.qbix.com/guide/pages
In our framework, we've always supported the concept of Pages and Tools (components to put on the pages). We handle all the swapping of CSS/JS, loading what you need only on demand, caching (even in the phonegap bundle!), retaining tools you still need while pages get replaced (instead of re-constructing them expensively from scratch every time). And of course removing event listeners for tools and pages which have been unloaded.
Ideally, all your pages should be cacheable to the point of being static, with dynamic content being populated by JS.
Also there is a security implication with CSRF. If you use a nonce in the session to prevent CSRF then this nonce has to be delivered to the client, either with the first page rendering, or -- if the page is cached -- on subsequent requests.
The point is ... it takes a long time to build all the supporting technology. We've done it. But it took us years!
You can check out an SPA here on desktop, tablet or mobile:
If you want detailed guidance on how to build SPA apps in a right way then you need to check out this guide (called Project Silk) from Microsoft [1]. It contains lot of insights and all the approaches provided are still applicable in 2015.
It comes with complete source code.
[1] - https://msdn.microsoft.com/en-us/library/hh396380.aspx
Most of the issues reported by this article are not a problem with it thanks to its approach.
Disclaimer: I have contributed to the project.
Look, I'm all in favor of SPAs; I build them myself. But when I trip over something that does infinite scrolling, I groan, because I know that if I should happen, twenty pages in, to slip and left-click a link instead of right-clicking and "Open in New Tab", I'm going to lose my place and have to start over from page 1 and spend five minutes wearing out my scroll wheel to get back to where I was -- either that, or shrug and give up on whatever I was reading.
There are real problems in the space. They need to be either solved or avoided. (If you can't get infinite scroll to work right, then don't use infinite scroll.) Pretending they don't exist and refusing to address them is just foolishness.
(I'm not sure where back-button-undo would be better than an undo button within the app, but I wouldn't rule it out. Maybe in a graphics editor where it would be convenient to use the mouse's back button.)
I would personally categorize an online discussion forum as a web site but something like Slack as a web app. But I would expect the back button to behave similarly between the two.
One you cherry pick SPA attempts, like with Twitter. This is an example of a company trying to refactor for SPA, not doing SPA from the beginning.
Libraries that help with SPA are maturing. It's easy to implement routing with backbone for example. You just have to be a good developer and actually learn.
The part that really matters is being a solid dev. Not if you choose SPA or not.