Reputation: 18316
i have a general question : is loading data via Ajax totally faster than loading the whole page to grap data regardless of page size(external elements like images,css file,js file ...) ?
Upvotes: 3
Views: 3806
Reputation: 9966
In practice, AJAX is always "faster". Not the request itself; that's approximately the same. The difference is that it transfers only the necessary minimum (if well written), doesn't start the whole page over (from CSS parsing, rendering, building the whole DOM, etc), and you do it in the background while the page is still visible so you can do other things, like animating stuff or even updating in advance, predicting the obvious results. A blessing for user experience.
But there's more.
The most important is the order of things. When you load a page, markup arrives first, then scripts and styles, and usually images come last. Only after all this processing will your page have the real look. Now when you change (even the whole) markup with AJAX, things are immediately in place, then a few of them change as your browser realizes the consequences. In other words: a page reload becomes visually "done" when everything is done; AJAX changes show up immediately. This is the real power of it. You already have all images, all lists, all everything, and you load only what's changed.
So: yes, it's a lot faster.
Upvotes: 1
Reputation: 1954
As already mentioned, using AJAX methods, lets you avoid reloading most of the page, including the scripts, styles and images even though the AJAX request and response may not be any faster.
It is also important to note that a slick, subtley animated modern AJAX interface often feels much faster than it is to the user. Reloading the page, seems to have the effect of resetting something in the brain, whereas just updating the relevant parts of a page in a smooth way makes everything just 'flow' together.
Very subjective, I know. Any good designer probably has a better way of explaining it.
Upvotes: 7
Reputation: 38533
@Spender is correct, but the main reason is that you do not re-grab the images, css, js and any other asset of the page. The request itself may or may not be faster but the final rendering is.
Upvotes: 5