isomorphic-git tries not to block the main thread, it still does on occasion.
This can cause your webapp to stutter or even freeze up briefly!
To achieve buttery smooth performance, you'll eventually want to move all your
isomorphic-git usage off of the main thread.
Actually, you should move all your logic that's not directly responsible for updating the DOM off the main thread.
That's still a real challenge in 2020, but more and more libraries are appearing to help solve this.
WebWorkers live in a separate operating system thread from the main JS thread and communicate using the worker.postMessage() method. Code in the worker thread does not have access to heap objects in the main thread. So all objects sent via postMessage need to be serialized before being sent. Technically, this is done using the structured clone algorithm.
What kinds of Objects can be sent using
postMessage? Functions cannot. Therefore objects with methods cannot.
JSON objects can.
Date objects and
RegExp objects can. Also
Uint8Array objects and
Map objects and
Here is a complete example that runs git in a WebWorker.
The worker wraps some git functions and exposes them to the main thread, while the main thread exposes some functions to the worker for use in callbacks like