Just FYI, JavaScript has Atomics in its spec, but it has more or less been stalled for the last 3 years, probably due to security vulnerabilities (Spectre and Meltdown). ECMAScript® 2024 Language Specification
Discussions suggest it’s only temporarily disabled, but I wouldn’t hold my breath SharedArrayBuffer - JavaScript | MDN
There currently isn’t good browser support Can I use... Support tables for HTML5, CSS3, etc
I think it’s intended that WebAssembly gets a similar implementation after MVP. But I imagine it will have the same implementation complexities. https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md
Overall with that in mind I think this is the most pragmatic, expedient, maintainable, and future proof solution: