That is half of what I would need for a project, the other half being Clang itself running in the browser (to use for teaching). In theory there is [1] since many years, but in practice it never worked for me (even now I get "Runtime error: memory access out of bounds").

[1] https://tbfleming.github.io/cib/

I'm investigating v86 [1] (x86-compatible CPU and hardware emulator in JS) to get a c compiler in the browser. There's an example with a 5.5 mb Build Root Linux example [2] where you can pass files and commands between the browser and vm. The vm boots within a few seconds in Firefox on my Pixel 2 XL. There's also an example where Lua code is passed from the host, but you have to download the GitHub repo to see it [3]

It likely isn't suited for compiling big c programs, but I think one can get far with preparing a few shared libraries and Tiny C Compiler or similar.

[1] https://github.com/copy/v86

[2] https://copy.sh/v86/?profile=buildroot

[3] https://github.com/copy/v86/blob/master/examples/lua.html