Friday, August 21, 2009

Javascript Sockets

Is this idea even possible? Can javascript sockets actually exist inside javascript applications? According to this entry, this reality isn't too far-fetched after all. One of key problems this will solve is the current polling requirement of most javascript applications. These applications need to poll the server for state changes so that these changes, if they have taken place, can be reflected in the UI. This is an expensive operation that often yields nothing in return. So, we have this expensive process that is need just in case of a server state change. Below is an illustration of a polling javascript application.



Both Flash and Java Applets are components external to the browser that allow connection sockets to communicate with the server. It seems counter-intuitive to be using a web browser that doesn't work with most of the web without a separate software installation process. The ideal situation would be to provide the javascript application with a socket. This would eliminate the need for both a library external to the browser as well as the need for polling. Below is an example of what a future javascript application without the polling requirement might look like.