HTML and CSS Reference
In-Depth Information
It was not until 2005 that the postback flickering was bypassed thanks to Asyn-
chronous JavaScript and XML ( AJAX ).AJAXisbasedontheJavaScript's XmlHt-
tpRequest Object and allows asynchronous execution of JavaScript code without
interfering with the rest of the user interface. Instead of reloading the whole page,
AJAX sends and receives back only a portion of the web page.
Imagine you are using Facebook and want to post a comment on your Timeline. You
type a status update in the proper text field, hit Enter and... voila! Your comment is
automatically published without a single page load. Unless Facebook used AJAX,
the browser would need to refresh the whole page in order to display your new
AJAX, accompanied with popular JavaScript libraries such as jQuery, has strongly
improved the end user experience and is widely considered as a must-have attribute
for every website. It was only after AJAX that JavaScript became a respectable pro-
gramming language, instead of being thought of as a necessary evil.
But it's still not enough. Long polling is a useful technique that makes it seem like
your browser maintains a persistent connection, while the truth is that the client
makes continuous calls! This might be extremely resource-intensive, especially in
mobile devices, where speed and data size really matter.
All of the methods previously described provide real-time bidirectional communica-
tion, but have three obvious disadvantages in comparison with WebSockets:
• They send HTTP headers, making the total file size larger
• The communication type is half duplex, meaning that each party (client/serv-
er) must wait for the other one to finish
• The web server consumes more resources
The postback world seems like a walkie-talkie—you need to wait for the other guy
to finish speaking (half-duplex). In the WebSocket world, the participants can speak
concurrently (full-duplex)!
The web was initially built for displaying text documents, but think how it is used
today. We display multimedia content, add location capabilities, accomplish complex
tasks and, hence, transmit data different than text. AJAX and browser plugins such
as Flash are all great, but a more native way of doing things is required. The way we
Search WWH ::

Custom Search