How can I use HTML5 web workers with Google Closure Tools?

I need to do some computationally intensive things against the background of my application, and I learned about HTML5 web workers. Is there an integrated way to do this using Google Closure tools? I found gears.Worker , but I don’t understand if this class fits the bill or how to use it. Thank!

+5
source share
1 answer

Using Web Workers does not require anything special from the closure library, unless you want to start bootstrap / webworkers.js without compiling it. It is used like this

/**
 * Closure dependency management, require only main worker script of un-compiled version.
 */
if (typeof COMPILED == 'undefined') {
  CLOSURE_BASE_PATH = '../../../closure-library/closure/goog/';
  importScripts(
      CLOSURE_BASE_PATH + 'bootstrap/webworkers.js',
      CLOSURE_BASE_PATH + 'base.js',
      CLOSURE_BASE_PATH + 'deps.js',
      '/your-script.js');
} 

gear -. , .

+3

All Articles