Let's say I have a website where each user has a profile.
Now an user with an existing profile wants to edit it, so he clicks on a button "edit my profile".
Let's assume that the UI allowing the user to accomplish this is complex and takes some time to be rendered (100 ms).
The AJAX call to the server to retrieve the profile data takes 150 ms.
Once "edit my profile" is clicked I would proceed as following:
- show a loading indicator
- make the ajax call (150 ms)
- as the ajax call returns build the UI and fill it with the data returned (100ms)
total time: 250ms
But... what if I would proceed in this other way:
- start the ajax call
- build the interface (with no content), maybe locking it with a modal popup on top which says "loading..."
- when the ajax call returns unlock the interface and fill it
Does the browser start an AJAX call immediately, or does it wait for the current operation to finish?
Because if it does, this should be faster since it constructs the UI while making the AJAX call, taking 150 ms (overlapped UI construction + AJAX call) + let's say 20 ms to update the UI.
total time: 170 ms.