MV Seeking guidance in regards to background processes and initialization

I'm relatively new to JS and programming in general, so apologizes if I'm asking something that might be obvious.

My first question is related to background processes, specifically processes that need to occur every frame. In the case of my game, that would be updates to the various HUD elements I have onscreen while on the map scene.
I'm currently using parallel common events in order to handle the updates by writing new functions to the game interpreter, but I've noticed that plugins are not doing it this way, and would alias the refresh/update functions of other objects (mostly scene_map or game_map) instead for constant updates.
I'd like to know if there's a definitive "better" way of doing it, in terms of performance and accuracy of the updates?

My second question may be more suitable for plugin support, but since it doesn't pertain to any specific plugin I might as well put it here.
My game relies heavily on spawning events, and given that spawned events are not present on the map when it first loads, those events aren't affected by any processes provided by plugins that alias the initialization of scene_map or game_map. Once I load the map a second time, everything is fine of course, but I'd like to find a solution.
If I want to spawn events when scene_map or game_map initializes for the first time in a playthrough (only the first, and not in any subsequent updates), which function should be aliased and how would you make sure it only happens the first time?
If I want to spawn events when scene_map or game_map initializes for the first time in a playthrough (only the first, and not in any subsequent updates), which function should be aliased and how would you make sure it only happens the first time?
Can't you have an autorun/parallel event that does all the spawns on initial game load then self switch A to a blank page at the end?
Can't you have an autorun/parallel event that does all the spawns on initial game load then self switch A to a blank page at the end?

What do you mean by "initial game load"? if an event on the map is running a command, doesn't it always happen after the map has already been loaded?
I'm currently using parallel common events in order to handle the updates by writing new functions to the game interpreter, but I've noticed that plugins are not doing it this way, and would alias the refresh/update functions of other objects (mostly scene_map or game_map) instead for constant updates.
I'd like to know if there's a definitive "better" way of doing it, in terms of performance and accuracy of the updates?
Parallel common events and aliasing the update functions are technically the same. The refresh function, however, is only called once when it is needed.

Refresh is usually trigger-based. For example, when you move the cursor from item to item, the description changes, that is refresh function doing its job. Depending on what you need, this is probably what you are seeking. The better way of doing it. You can still check if the value changes each frame, but the refresh would only happen when the value changes.

If I want to spawn events when scene_map or game_map initializes for the first time in a playthrough (only the first, and not in any subsequent updates), which function should be aliased and how would you make sure it only happens the first time?
The answer is Game_Map.
Scene_Map is to handle the map screen, including adding windows and other HUD. Game_Map handles the game data such as the event position, etc.

To make sure that it only initializes the first time, you can have an object or array to store the map ID. For example, adding this._loadedMap = []. Before the map is loaded, check if the ID is present in this array. If it is not, execute the code that should run for the first time, then add the map ID to this array.

But I don't have the MV/MZ code open to answer which function to alias right now.
What do you mean by "initial game load"? if an event on the map is running a command, doesn't it always happen after the map has already been loaded?
I meant the first time you start the game and land on that map. I assumed it was the starting map. If you have an event run its commands, in this case all your spawn commands, then toggle its self switch it shouldn't ever run again.

Original thread: https://forums.rpgmakerweb.com/threads/seeking-guidance-in-regards-to-background-processes-and-initialization.157410/