Using RoughJS in Web Workers

If you want to delegate most of RoughJS computation to a web worker thread, it is really simple.

Simply include Workly (only 1kB gzipped) in your page and set the async property in your config; and RoughJS will automatically move most of the processing to a worker.

<script src=""></script>
let canvas = rough.canvas(canvasNode, { async: true });

If you want to use workly, but not use the default CDN to load it in the web worker, pass the URL to RoughCanvas at instantiation.

<script src="{Custom URL for Workly}"></script>
let canvas = rough.canvas(canvasNode, { async: true, worklyURL: customURL });

Leave a Comment

Your email address will not be published.