<!-- Page: https://rustic-game-engine.pages.dev/docs/scripting/javascript -->

# Scripting Rustic games with JavaScript

JavaScript is bundled and sandboxed. A script assigns one behavior object to
`globalThis.behavior`; it does not export a Node module and cannot use Node or browser
APIs. Create `.js` or `.mjs` gameplay files with the editor so an Asset ID and the
chosen global, scene, or component attachment are created automatically.


JavaScript placed under the project's top-level `ui/` folder (including nested
folders) is automatically categorized as Web/UI code. It keeps the same lifecycle,
scene access and `Events` APIs; attachments still determine when it runs. See
[UI JavaScript and gameplay signals](https://rustic-game-engine.pages.dev/markdown/scripting/web.md#javascript-in-ui) for setup,
a working example and runtime limitations.

## Topics

- [Behavior lifecycle](https://rustic-game-engine.pages.dev/markdown/scripting/javascript/behavior-lifecycle.md)
- [API reference](https://rustic-game-engine.pages.dev/markdown/scripting/javascript/api-reference.md)
- [Scene, instances, cameras, and input](https://rustic-game-engine.pages.dev/markdown/scripting/javascript/scene-instances-cameras-and-input.md)
- [Sandbox, values, and diagnostics](https://rustic-game-engine.pages.dev/markdown/scripting/javascript/sandbox-values-and-diagnostics.md)

## Related guides

- [Edit scene objects](https://rustic-game-engine.pages.dev/markdown/guides/scene-objects.md)
- [Use gameplay actions](https://rustic-game-engine.pages.dev/markdown/guides/gameplay-actions.md)
