wrun

The wrun allows you to dynamically run a function inside a Web Worker on the client side, without the needing of a dedicated file. This means that you can execute a JS function as a subprocess, avoiding the slow down, break or freeze the main thread. This lib is also minimal: 811 bytes.

For installation, usage and general docs:

Docs / Github

Demo

Lets run a function that keeps calculating the seconds distance between two Dates inside a while for a given interval of time; 5 seconds by default. This will drastically slow down the current thread processing power. The function:

      

To know if the runtime is ok, look at the counter here which is being automatically incremented by 1 sec. If the counter gets freezed, means the main thread gots freezed.

You can observe that when you run this function normally, the current thread gets freezed for a few seconds, but when you run the same function over wrun the main thread does not slows down because wrun will be executing our function in another thread/subprocess. You can even click multiple times on "Run with wrun" without harm your main thread.

Runtime check: 0
Open your console and check the output

About

wRun is a lib written by Felippe Regazio