Freeing up thread models with web workers


Traditionally, Javascript operates in a single-thread model. Any process that needs Javascript - from creating the DOM to rendering a visualization - must wait in line with every other Javascript operation before it can do its thing.

Recently, while working with a large and complex data grid, we discovered that we had an algorithm that took five whole seconds to complete. (That doesn't sound long, but user attention spans are notoriously short.) First, we tried to delay that calculation so it did not start until the rest of the page had loaded. But even then, we found that while the task executed, it completely froze up the UI, leaving the user unable to scroll, click, or do anything but beachball and wait.