PeculiarVentures / webcrypto-liner

webcrypto-liner is a polyfill that let's down-level User Agents (like IE/Edge) use libraries that depend on WebCrypto. (Keywords: Javascript, WebCrypto, Shim, Polyfill)
MIT License
149 stars 26 forks source link

Uses web workers when available #1

Open rmhrisk opened 7 years ago

rmhrisk commented 7 years ago

Web workers use separate threads of execution to perform work in parallel with the main thread.

We can detect if web workers are supported and degrade if it is not:

if( window.Worker /*check for support*/ )
    someObject.myFunction = function() { /*algorithm that uses Web Workers*/ }
else
    someObject.myFunction = function() { /* sad face */ }

Web workers are instantiated by calling:

new Worker(pathToJavaScriptFile);

Here is a useful post on this topic: http://codecube.net/2009/07/cross-platform-javascript-webworker/