开发者

When to use dynamic content and when to switch to another page?

How is content organized on modern sites? For example on Google+ w开发者_Python百科here does dynamic loading end and a new page begins? Which approaches do you know of? What is considered as state-of-the-art?


I understand the question you are asking, but I don't quite understand your bullet points. However, as far as I know, there are no "standards" when it comes to dynamic loading vs full page reloads. This does not mean, however, that we should blindly apply what we know about these two concepts to make an informed decision!

Dynamic page loading is useful for many reasons:

  • We can update only parts of the DOM, which means for a site like G+, they need not require the client to refresh the left, right, and top panels when something in their stream gets updated
  • Because of ^, we get (Seemingly) more responsive applications, which creates a better user experience
  • Reduced traffic from the client to the server, which can potentially increase performance
  • Other elements on the page are not directly affected, if the script runs into an error, you can handle that without disrupting other parts of your DOM

So with these points we can really say that G+ would like to take advantage of AJAX and create the best user experience. But there are some parts of G+ that still do full page reloads, like the "Go Mobile" section on the right. But that's obvious because you are completely changing the whole layout of the page so it's unnecessary to use an AJAX call. Also, there are probably other applications that might redirect to this page, so it would not make sense for those other pages to have to make the same AJAX request on the same elements of the website (you can think of better examples of this).

So the answer to your question? There is nothing considered state-of-the-art and it depends on the application you want to create. But a good rule of thumb is to basically use AJAX whenever you can. It is definitely more work in terms of the amount of man hours but it is very rewarding. More likely than not, you're going to be creating an application that revolves around one layout (as with 90% of all social networking websites right now), so try to keep all actions in that layout to be dynamic. Once you move away from that layout, then it's good to do a full page reload so you can gather and organize the right resources for you do handle THAT layout's AJAX requests.

Lastly, there are some things that you simply cannot do unless you use JavaScript. For example, Facebook dynamically appends to your posts when there are new comments, you need not refresh your page for these new comments to appear. This simply cannot be done without JavaScript, so if your application require such features, then you must use JavaScript.

I'm not sure how much this helps you, but these are the things I think about when creating a web application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜