With the rise of the upcoming WebWorkers API in the horizon, interesting things are emerging. And the one that got me go "whhaaaaat??" is the one that advices you to put all of your business logic inside a WebWorker. Whaaaaat?

A WebWorker is a separate thread that runs Javascript but has no access to the DOM or the window object. But it can do complex queries and loops, accessing core functions and APIs, while you are letting the main thread, the UI thread, to handle the UI stuff only.

Rendering the DOM is so expensive, specially when it comes to complex interfaces we have nowadays. Not so long ago, the VirtualDOM introduced which tried to speed up the rendering process by rendering only what actually changed, instead of re-rendering the whole page. But, that's not enough apparently, since even such few changes can't be handle well by low powered devices such as mobiles phones and watches.

In order to keep the 60fpm barrier, we are completely freeing the main thread to be able to handle the rendering only and we start WebWorkers to handle our business logic.

I found two great examples of this concept. Both, they are suggesting keeping the whole app outside the main thread and send there only the patch of the changed DOM to be rendered. The UI thread can then handle only rendering and complex fancy animations.

Oh, by the way, Nodejs fans, Workers are coming.