RoughJS in a web worker

Preet edited this page Mar 19, 2018 · 4 revisions

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="https://cdn.jsdelivr.net/gh/pshihn/workly/dist/workly.min.js"></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 });
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.