title: Initializing web workers
body: <p>It seems the only communication from host to <a href="https://html.spec.whatwg.org/multipage/workers.html#dom-worker" rel="nofollow noreferrer">worker</a> is <code>postMessgage</code> and <code>onmessage</code>. If the worker requires some dynamic initialization (as in constructor, here: regular expression to use later), what is the best way to do this?</p>
  
  <p>A possibility would be to let <code>data</code> be an object, and have e.g. an <code>action</code> parameter, and to check this on every run. This seems a bit kludgey.</p>