This example is intended for beginners. However, I will assume that you have some basic knowledge about Web development, JavaScript and IFC.js.
Also, please note that this part is only an explanation of the concepts. Take a look at the next chapter (Developer Guide) to see step by step instructions.
Web Workers
What are Web Workers?
JavaScript is a single-threaded environment, meaning multiple scripts cannot run at the same time (1). However, Web Workers makes it possible to run a script operation in a background thread (2).
A Web Worker is a JavaScript script that runs in the background, independently of any other scripts, without affecting the performance of the page (3).
What can Web Workers do?
Web Workers are a simple means for web content to run scripts in background threads. Once created, a worker can send messages to the JavaScript code that created it by posting messages to an event handler specified by that code (4).
Certain types, say Functions, are NOT supported by the structured clone algorithm. Therefore, we cannot build the entire IFC Project in a Web Worker.
Why can't I build the entire IFC Project inside a Web Worker?
The mainObject, used in src/ifc-project-builder/ifc-structure-builder.js, contains some nasty stuff. The structured clone algorithm cannot deal with that type of object.