title: How to load inline Javascript with webworkers?
body: <p>As far as I can tell, web workers need to be written in a separate JavaScript files. But How can I load the following inline Javascript with webworkers?</p>
  
  <p>The following script is a example of three.js. Three.js is a JavaScript 3D Library which makes WebGL simpler.</p>
  
  <pre><code>&lt;script&gt;
    var scene = new THREE.Scene();
  var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
  
  var renderer = new THREE.WebGLRenderer();
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement);
  
  var geometry = new THREE.BoxGeometry(1, 1, 1);
  var material = new THREE.MeshBasicMaterial({
    color: 0x00ff00
  });
  var cube = new THREE.Mesh(geometry, material);
  scene.add(cube);
  
  camera.position.z = 5;
  
  var loader = new THREE.JSONLoader();
  loader.load("mesh1.json", function(geometry) {
    var mesh1 = new THREE.Mesh(geometry, material["demomaterial"]);
    scene.add(mesh1);
  });
  loader.load("mesh2.json", function(geometry) {
    var mesh2 = new THREE.Mesh(geometry, material["demomaterial"]);
    scene.add(mesh2);
  });
  loader.load("mesh3.json", function(geometry) {
    var mesh2 = new THREE.Mesh(geometry, material["demomaterial"]);
    scene.add(mesh3);
  });
  var render = function() {
    requestAnimationFrame(render);
  
    cube.rotation.x += 0.1;
    cube.rotation.y += 0.1;
  
    renderer.render(scene, camera);
  };
  
  render(); 
  
  &lt;/script&gt;
  </code></pre>