Crate embed_js [] [src]

This crate allows you to embed inline javascript in your Rust code for use with the wasm32-unknown-unknown target. Crates also need to use the embed_js_build crate in their build script (see that crate's documentation for more details). Crates that generate binaries must also use embed_js_build in a post-build step to collect the generated accompanying javascript from itself and all dependencies.

See the documentation pages of the macros in this crate for more details and examples. The embed_js repository also contains example projects.

Macros

embed_js_preamble

For every crate that uses the js macro directly, the embed_js_preamble macro must be called at least once somewhere in the crate, for example

include_js

Used to specify JavaScript that should be executed before the WebAssembly module is loaded. This is useful for specifying functions that can be shared between instances of inline JS, or set up other global state. This macro is used as a statement or at item level.

js

Call javascript, inline.