title: Require.js optional module loading
body: <p>I am looking to integrate Require.JS into my project which requires the ability to switch dependencies based on the client.</p>
  
  <p>Currently I have some background processing that is performed using web-workers, in the future I would like the option to have the processing performed on a server which should involve just replacing a module.</p>
  
  <p>Currently the only approach I can think to have the following pseudo code in my main script file :</p>
  
  <pre><code>var modules = [];
  // This would be done with Modernizr or with a simple hasOwnProperty check
  if(window.hasFeature('web-workers') {
      modules = ["other-dependencies", "webworker-calc"];
  } else {
      modules = ["other-dependencies", "server-calc"];
  }
  require(modules, function (deps, calc) { // Code goes here };
  </code></pre>
  
  <p>Is there a cleaner approach to doing this? Can I leverage Require.JS more than I am in the above example?</p>