This was already in the server for 5-6 or more years

The only problem is that it's only detecting if (created) {} scripts by default, while npcs with function onCreated() are not 'optimized away' right now. So you have to call this.scriptdone(); yourself on those objects.
The big advantage is that those npcs don't appear in level.npcs[] anymore, which speeds up findareanpcs() or scanning levels.npcs[].