You don't really run anything "in egui" - Egui is a library you call into. The online Egui demo is done with
egui_web, which is a pretty simple library that just hooks up to some callbacks for input and paint events using
If you want to spawn a web worker I think you can do so from either JS or in Rust with
js-sys / wasm-bindgen. If you want to call Egui code from that worker, that should be no problem.
I hope that helps!