I am building an application and I'm very much using the SPA (Single Page Application) approach. This means my page never reloads and everything is done through AJAX or sockets. However, I do have one exception: The login/logout is done in the traditional way. So, my application is essentially two SPA's one "public" (if you're not logged in) and a "private" (for logged in users).

I was wondering if other people have adopted my approach or if I should instead try to make a single SPA. Here are few advantages/disadvantages I can think of.

Advantages (of having two SPA's)

  • When the user opens the public app, he doesn't have to load all of the "private" assets which can be quite substantial. This makes the initial page load faster.
  • The page load makes the user feel something has happened. This is hard to explain but, it's kinda like that feeling when you see the gmail loader fill up and your app appear.


  • I think the process of login/logout is slower because each time you have to reload the assets.
  • We're breaking away from the SPA approach.
  • More server requests which can potentially slow down the server.

So yea I'm just curious if people have you used my approach before or if the have other pros/cons to add.

  • 1
    The point of logging out is to get rid of the data on screen, so I think most people would want the page to refresh...possibly to a mostly blank 'you have successfully logged out' type of message. – DA01 Mar 21 '14 at 20:55
  • I have a similar app and I have a separate login page precisely for the advantages you list above. Plus I think it is safer. – pathfinder Mar 22 '14 at 2:29

I faced that scenario and i find out that having an AJAX login is more complex than a refres login.

A AJAX login requires 2 things:

  1. dont allow access to the user to related app. You can do this by placing a div in from but can be remove it by opening the console and delete that login. Which in some way you have to strictly block access if the user is not log in.
  2. Once the user log in successfully. You have to load the whole app by AJAX that may produce some issues if your target browsers include ie8-9.

And a bonus:

  1. The response, if the application is kind of heavy, can be much lower than actually load the app directly which will affect the user experience.

  2. I've Never seen an AJAX login

| improve this answer | |

I was dealing with this a couple of years back - was working on a system that had an Ajax login/logout (using ExtJS) and one that did it with a separate login page.

I can hardly remember any of the reasons, but do remember we had a multitude of issues with the ajax login.

The one I remember the most was security - the submit as done via traditional page refresh is more secure than sending passwords over ajax (effectively making the script aware of the password and letting anyone with access to the computer to see the password in FireBug or Chrome developer tools). There a bit of debate about this on StackOverflow, so would look in there.

I also vaguely recall problems with session timeouts.

I'm sorry that this isn't the most detailed answer, but do make sure that if you do the Ajax login, you are aware of all the complexities.

| improve this answer | |
  • +1 "the submit as done via traditional page refresh is more secure than sending passwords over ajax" – Misters Jun 5 '14 at 12:39
  • The security of the postback login comes from being able to set HttpOnly cookies, which you can't do with an XHR. You don't need to a do a whole page refresh though if you log in through an <iframe>, which is perfectly capable of setting the right auth cookie. – Michael Kropat Aug 3 '15 at 17:38
  • 2
    Again, I'm not 100% knowledgeable on this issue. But the developers I work with say that it marks no difference nowadays: Ajax or not - it's a request made to the server and would be equally secure if implemented correctly. – Izhaki Aug 10 '15 at 21:23
  • Another problem is that Chrome and other browsers don't offer to remember passwords if you submit the form by AJAX. – Buttle Butkus Mar 23 '19 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.