1# `start` 2 3When attached to a `pub` function this attribute will configure the `start` 4section of the wasm executable to be emitted, executing the tagged function as 5soon as the wasm module is instantiated. 6 7```rust 8#[wasm_bindgen(start)] 9pub fn main() { 10 // executed automatically ... 11} 12``` 13 14The `start` section of the wasm executable will be configured to execute the 15`main` function here as soon as it can. Note that due to various practical 16limitations today the start section of the executable may not literally point to 17`main`, but the `main` function here should be started up automatically when the 18wasm module is loaded. 19 20There's a few caveats to be aware of when using the `start` attribute: 21 22* The `start` function must take no arguments and must either return `()` or 23 `Result<(), JsValue>` 24* Only one `start` function can be placed into a module, including its 25 dependencies. If more than one is specified then `wasm-bindgen` will fail when 26 the CLI is run. It's recommended that only applications use this attribute. 27* The `start` function will not be executed when testing. 28* If you're experimenting with WebAssembly threads, the `start` function is 29 executed *once per thread*, not once globally! 30* Note that the `start` function is relatively new, so if you find any bugs with 31 it, please feel free to report an issue! 32