How to use web worker?

How to use web work in meteor ? it requires to read a js file, but all js file will be loaded as app in meteor.
Or, without web worker, how to do background job without affecting the front performance ? (such as processing image)

I wrote a meteor package to wrap webworker-threads which allows you pass a function directly to the worker (no need for a file). If you’re trialling meteor 1.3 you’ll be able to use the npm package directly. There’s no “meteor context” in the worker, so your code needs to be vanilla - but it does work well.

Edit: you could also look at differential:workers.

1 Like

@robfallows Did you push your meteor package to atmosphere?

No. It was more in the nature of a personal experiment (no documentation) and there’s enough unmaintained noise on atmosphere without me adding to it :wink:!

In any case, if I was looking at this today I’d expect to be using it with Meteor 1.3, so I’d just use the npm package directly.

Makes sense. Thanks for the followup!

Any examples of this would be great?

I use web workers extensively in a Meteor app, this package is all you need. It allows you to provide a function instead of a file.