# Run script example

This example demonstrates calling `emscripten:run_script/1` and `emscripten:run_script/2` to run Javascript from Erlang.

It displays three alerts:

- An alert in the main thread, synchronously
- An alert in the main thread, asynchronously
- An alert in the worker thread

Second alert is likely to appear after third alert.

On non-SMP builds, it demonstrates the fact that Erlang continues to run when `emscripten:run_script/2` is called with `[main_thread]` as a counter is incremented while waiting for first alert to complete. The value is unset

Beyond the counter, this example also demonstrates manipulating DOM (in the main thread) using JS function.

Style of this text was not modified by Erlang.