> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selvut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Performance

> Keeping scripts cheap and predictable.

Event callbacks run frequently. Keep `tick`, packet, and render callbacks short.

Use `Script.throttle` for periodic work:

```lua theme={null}
Script.on("tick", function()
  if not Script.throttle("scan", 500) then return end
  local entities = World.getEntities()
  Chat.log("entities: " .. #entities)
end)
```

Use timers for repeated work that does not need every tick:

```lua theme={null}
local id = Script.setInterval(function()
  Chat.log("TPS: " .. tostring(Client.tps()))
end, 1000)

Script.on("disable", function()
  Script.clearInterval(id)
end)
```

Use `Script.thread` only for work that needs blocking waits. Do not call `Time.sleep` in event callbacks.
