WebSockets and the Future of the Web


What Are WebSockets?

WebSockets are one of many new technologies coming to the web that should have people excited. WebSockets will allow real-time, two-way communication between the browser and the server. While this article won’t be getting into too much technical detail, if you are interested you can find more detailed information at the resources listed below.

A Brief Look Back

In the past a browser would make a request to a server and the server would respond with the content requested and that was all. The problem with this is that if something were to be updated on the server, the browser would not be made aware of it unless it made another request.

The solution to this was AJAX (Asynchronous JavaScript and XML). This allowed the browser to make requests in the background without reloading an entire page and gave websites a more real-time feel that wasn’t possible before. Eventually the use of AJAX exploded in the late 2000s and became very common as it has shaped our modern browsing experience.

Where it Stands Today

There are two standards to WebSockets. One is the protocol that determines how the client and the server will talk to each other. The other is the API that the browsers will implement with JavaScript. Both of these standards have begun to stabilize now, allowing for more widespread use.

The WebSocket API is available in all of the latest browsers including mobile. For the latest information on WebSocket availability you can check here. This is all great news from the browser side of things, but the server side gets a little bit more complicated.

There are a lot of server side libraries for a wide variety of languages to choose from. A good list can be found here. The only problem is that the technology is still very new and current hosting plans and web servers are not optimized to use WebSockets at this point.

As of today, using WebSockets is a viable option, but because of how new it is, the road may still be a little bumpy. As the use of the technology spreads it should become easier to implement, which will continue to increase its use.

Why We Are Excited

Here are just a few key benefits to WebSockets:

  • Reduced network traffic. With WebSockets, there doesn’t need to be a full request/response for each new piece of information transferred.
  • Near instantaneous communication. Real-time sales or pricing is a good example of something that requires as little delay as possible when sending and receiving information.
  • Two-way communication. Being able to push from both the server and the browser can change the way websites are used.

The most exciting thing about WebSockets is all the new opportunities it will present. Like most new technologies the early applications of it will be rather obvious. Things like in-browser chatting, multiplayer gaming, real-time sales or pricing information, etc. are straight-forward applications of WebSockets.

What could be more interesting are the things we haven’t thought of yet. In the beginning AJAX was being used in simple ways, like grabbing parts of a page to keep it updated. But now AJAX can be used to build one-page apps and is a driving feature of many JavaScript frameworks. WebSockets could follow a similar path.

Perhaps these Javascript frameworks will move to WebSockets over AJAX. Perhaps, in conjunction with the also exciting WebRTC technologies, the social internet could have a whole new, personal feeling to it. Perhaps it will allow in-browser gaming to take a major leap forward. Perhaps online collaboration will allow us to change or build websites in real-time through live user input. And most likely they will be used in ways that are yet to be discovered. 

Because of all these possibilities, it appears that WebSockets will be one of many new technologies coming out that will shape and define the future of the web.

Resources

WebSockets Protocol

WebSockets API

WebSockets Wikipedia

WebSockets defined on MDN

WebSocket.org

Join in the Discussion