What is the difference between the always-reloading and not-so-often-reloading websites?

4

2

This is one way I can classify websites:

a) those that reload on every little matter - you add a comment-they reload, the live score updates-they reload the whole page, instead of just the score..

b) some like superuser.com these websites do not reload when there is no need, like adding a comment, etc.

I find the second ones convenient, I guess everyone does. So why does not everyone make websites like that?

Technically, where does the difference lie among the two types I mentioned??

Lazer

Posted 2009-09-15T21:57:30.537

Reputation: 13 841

The reason you don't see more of the second types of websites is because it's harder to do, and requires more work. However, with tools that make this all super easy (like jQuery), expect more websites to take advantage of Ajax in the coming years. Almost every "new" website that I've been to has used it. – Sasha Chedygov – 2009-09-15T22:32:44.363

Answers

2

Technically, where does the difference lie among the two types I mentioned??

While AJAX is the common reason these days, the core of the answer is client-side scripting. After all, AJAX is nothing more than client-side scripting and there's plenty of other ways to make changes to and update a webpage without the need of a refresh. (See DOM in seanyboy reply).

Websites that provide scripts that run on the client machine (JavaScript being a common technology) allow for content to be processed and changed without the need for a server roundtrip. On the other hand, Server-side scripting (such as languages like PHP) are processed on the server, hence the need for a reload. The request is sent to the server, it is processed there and the new page sent back to the client where it is "refreshed".

A Dwarf

Posted 2009-09-15T21:57:30.537

Reputation: 17 756

"Websites that provide scripts that run on the client machine (JavaScript being a common technology) allow for content to be processed and changed without the need for a server roundtrip."

but suppose I add a comment on superuser.com , then there has to be a server roundtrip because the comment has to be communicated to the server?? – Lazer – 2009-09-16T06:14:33.410

Definitely. And for that you have been using a client-side scripting while employing a technique called AJAX :) OTOH, if you want to click the comment button and a comment field to expand without having to reload the page, you use client-side scripting, but you don't need to employ the AJAX technique. So, at the core of your ability is the nature of the scripti language. Client-side scripting allows for such things. – A Dwarf – 2009-09-16T11:25:39.460

7

Sites like SuperUser use a technique called AJAX it stands for Asynchronous JavaScript And XML. This means that they can update parts of a web page without reloading the entire page. This is what the other sites do. Sites using AJAX should be quicker as they don't have to send all the data for the page every time something changes.

Wikipedia has an article which is probably a good starting point, but there are lots of resources out on the web.

ChrisF

Posted 2009-09-15T21:57:30.537

Reputation: 39 650

I like your answer best so far, so am gonna add to it via comments, instead of adding my own answer... – Roy Rico – 2009-09-15T22:29:25.650

1I think it's important to mention that AJAX techniques provide a lot of functionality for normal users, but also present some drawbacks to users who need a website to be available to the handicapped (known as accessibly in web development terms). Many fun sites can provide an AJAX interface, without worrying about accessibly. However sites that are more serious (banks, utilities) need to provide accessibility, so in order to create the nice AJAX functionality they'd have to do twice the work, so many companies dont find it cost effective. (tho there's some disagreement about that) – Roy Rico – 2009-09-15T22:37:58.770

1Another reason sites don't use AJAX could be because the site was created before many AJAX techniques became mainstream, or the current developers are not familiar with AJAX techniques (or their management has't approved them to upgrade) – Roy Rico – 2009-09-15T22:38:28.923

Remember that the X in AJAX stands for JSON – Sam Hasler – 2009-09-18T19:11:31.353

3

AJAX programming allows you to update elements of the page dynamically. However, AJAX has a number of disadvantages over just displaying the webpage. These include:

  • They're harder to program. It's a lot tougher to do AJAX programming, and as a consequence, people will avoid it unless they have to.
  • They have "Client Side" and "Server Side Code". As well as writing code on the server side to display the page, you also have to write code that runs on the browser (Internet Explorer, etc) to do the dynamic updates. This takes longer, and is more difficult to get your head around.
  • Browser Standards. Certain web browsers (like the afore mentioned Internet Explorer) behave differently to the defined standards and other web browsers (like firefox). Older browsers may not work with AJAX at all. Mobile browsers (on your phone) may also not work with AJAX, or they may work with a subset of AJAX. Because of this, it may be better to make your web pages in a way that works across all browsers and not use AJAX.
  • AJAX is still pretty new. Because of this, a lot of programmers don't know how to create dynamic web pages. Also - older web pages / websites won't have AJAX in them. Finally, there is currently a lack of training and documentation with regard to the AJAX way of doing things.

I feel like some of these points may overlap, and some of the points I've made may be slightly contentious. I've also avoided talking about the DOM. However - I think I've got the basics.

DOM: Document Object Model. Loosely put, it defines how an AJAX program finds the place on the page to put/change the new element (e.g. a comment). Again, the DOM and how you access it differs from browser to browser. When you hear people moaning about what a bad browser IE6 is, it's because access to it's DOM is (a) broken (b) hard to use and (c) different to every other browser out there.

seanyboy

Posted 2009-09-15T21:57:30.537

Reputation: 1 568

(+1) for DOM. Indeed you can talk about it. It's at the core of client-side scripting. – A Dwarf – 2009-09-15T23:59:01.867