My question is. If I use Rust together with JS. For Rust to contact JS and for JS to contact Rust. Perhaps even for parts of the JS to contact each other.
Are these all compiled into one webassembly which the outside cannot re-program when first it is compiled. That is, will the JS files be part of the binary webassembly?
No, the Rust gets compiled to web assembly. The Javascript stays as Javascript. There is a clunky and slow way the communicate between each other in the browser.
Ironically Javascript is such a dynamic language it's not even possible to compile it to an executable code like was or any real native instruction set. Life would be much easier if we could use the browser interface directly from Rust/WASM instead of having to go through JS. I don't know if that is in any future time line though.
If someone makes a browser that natively allows other programming languages to interface. And just javascript being one of the choices. That could work.
What websites would need would be a double interface in the transitioning time. One for the new standard and one for the JS old standard. So if there was a backend able to send forward the right compilation depending on the browsers ability to run it. That would work.
I don't think web sites would need to change anything unless they want to. The same old HTML/JS/CSS would work as usual. The WASM and its interface to the DOM would be optional.
It's kind of crazy that there must be an API internally between the C++ that is the JS interpreter and the C++ that is the browser/DOM/etc and yet we can't get from the C++ that runs the WASM to the browser/DOM/etc.