Web Workers, Sockets and Intents. What?

Modern Web, also known as HTML5 brings with it a lot of jargons and keywords that baffle Web Developers.  Few among these jargons are – Web Workers, Web Sockets and Web Intents.  What are these?  Let’s see them briefly in this post, but mind this is not a tutorial – just an Intro post with links to good sources to learn more.

Web Workers

Multi Threading in Programming languages bring in the flexibility of Shared Namespace, Asynchronous processing etc. to the hands of Programmers.  Web Workers extend the Multi Threading concepts to the Web Browser.  This API defines the mechanism to spawn multiple background threads.  This allows you as a developer to do long-running, computationally intensive or blocking tasks in background scripts, thus offering a Non-Blocking UI to the end users.

As per the specification the Web Workers are heavy-weight components and must not be used in large numbers.  Also frequent creation and termination of Workers is not recommended.  Though they are useful for Background tasks like IO, Storage Access etc. they cannot access the DOM of the main page they are invoked from.  This makes sure that Workers cannot directly change the UI without the intervention of the Master.

  • You can find the Web Workers W3C Specification here
  • HTML5Rocks, as always has this nice introduction tutorial on Web Workers

WebSocket

WebSocket API brings in the concept of “open socket connection” between the Client (the Browser) and the Server.  This is in opposition to HTTP for Client-Server connection which is inherently “stateless” – WebSocket provide a way to maintain a persistent connection between the Client/Server for communication.

Like HTTP (and HTTPS), WebSocket uses a specific protocol WS (and WSS) for communication.  However, WebSocket are immature today and there is no inherent support yet on any Web Server.  But, using some libraries the WS protocol support can be achieved (refer to the links below for details).

  • WebSocket is backed by W3C and you can read the draft specification here
  • This nice tutorial on WebSocket by HTML5 Rocks will get you on speed with the API

This promising yet immature API is handy for applications like Multi Player Online Games, Chat Applications etc.  But we will have to wait and see the improvements and the support on various browsers.

Web Intents

Web Intents bring in the concept of Intents from Application Programming World.  It is a simple Javascript library (yet) created by a couple of German Web Developers, for Client-Side Service Discovery and Inter-Application Communication.

Consider Intent as an activity like “sharing a link on social media”.  List of Services like Twitter, Facebook etc. register and express their desire to handle this “Intent of Sharing”.  When this activity (or intent) is performed by the user, the library brings up the list of Services that have “expressed their interest” to the user.

This is very similar to “Intents” in the Android Programming language, just that it happens in the Web.

  • You can read more about Web Intents and watch some examples here
  • This short presentation also helps you appreciate why Web Intents are there

But note Web Intents are not a W3C Specification and also not supported inherently by any Browser yet.  It is a nice little concept and a library created by these developers.

So as Web Developers what do you think about these API?  Are you already using some in your Web Applications?  I am always curious to know about innovative use cases for new techniques.  I am listening!


Share this post:

Post on Twitter
Share on Facebook

Thoughts Unlimited runs on Genesis Framework


Comments

  1. Hi Ashwin, great article. I see that you worked on your elevator pitch ;) . Keep up the great writing. I’ve subscribed to your RSS to keep an eye on you :)

    • Hi Morne,

      Thanks for the comment and the appreciation. Yes I implemented the Day 1 lesson and hope to continue improving as I proceed on to Day 31 :)

Leave a Reply to Morné Cancel reply

*