# Implement a Web Worker

Our `Web Worker` doesn't do anything yet. Let's change that!

{% code title="example/web-worker/main.js" %}

```javascript
function readFile(input) {
    const reader = new FileReader();
    reader.onload = () => {
        const ifcWorker = new Worker('worker/worker.js');
        ifcWorker.onmessage = function (e) {
            // DO STUFF HERE
        };
        ifcWorker.postMessage(reader.result);
    };
    reader.readAsText(input.files[0]);
}
```

{% endcode %}

Just as the FileReader has an `onload` fucntion, the Web worker has an `onmessage` function. This function is called when the `Web Worker` is complete.&#x20;

To start the `Web Worker`, we [post a message](https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage). We want to post the result of the FileReader. Let's open our `worker.js` file.

{% code title="example/web-worker/worker/worker.js" %}

```javascript
onmessage = (e) => {
  const ifcData = e.data;
  
  let output = "Hello Worker";
  postMessage(output);
};
```

{% endcode %}

The `ifcData` variable contians the result from the FileReader. Note that this worker doesn't do anything yet. We simply return a string.&#x20;
