Why your FiveM script is slow at resmon
Most performance advice for FiveM scripts is folklore. I measured it. Here is where to look first.
Count what wakes up, not what exists
At resmon, thousands of sleeping threads are invisible. What costs is how often your code wakes up each frame. Before rewriting anything, count the loops that run every frame.
Wait(0) is not faster than Wait(5)
At around 87 frames per second, Wait(0), Wait(1) and Wait(5) behave the same. The server side has its own tick, much slower than the client: a short wait there does not mean what you think.
Exports are not free
An export call costs far more than a native read. One in a per-frame loop is enough to show up at resmon.
Where you allocate matters
Creating tables on the client is much more expensive than on the server. Some types cost almost nothing; knowing which ones is the cheapest optimisation there is.
NUI is not a normal browser
No WebAssembly, and recent CSS is missing. Recent build tools happily output what FiveM cannot run: check the built files, not the source.
RP Builder's scripts skill has the measured numbers behind each of these, writes scripts for ESX, QBCore, Qbox, ox or standalone, and measures their cost in game before you ship.