MZ Loading [data] across multiple frames

Good Morning,

I am working on loading data that takes longer than a frame to complete, but it is stuttering the main character's movement due to it not being able to be completed as quickly as I would like.

It appears RPG maker MZ creates a javascript game which at least in the browser is single threaded. Is my game going to be single threaded as well or are there advantages in this department because it is an application on the computer? Any tips or tricks on loading data across frames without affecting the user experience?

If I have to I will metaphorically "force the main character to crawl through a tight space" while I load the next area, but that significantly impacts my game design, so I need to figure out my options before I commit to a specific path.

Your opinion is appreciated.
Do i guess correctly, you also want to avoid a Loading Screen?
Do i guess correctly, you also want to avoid a Loading Screen?
Yes, I am trying walk from one map to another instead of transferring (warping) to the next map.

This would require me to load and unload map files while the game is playing. I have the ability to make this happen, but when a new map is loaded, to the right for example, the character is unresponsive until the load is complete, because it takes too long to load a file with JavaScript (no matter how small).
Generally speaking you will not know which map is going to be next, so I think you'd have to load all possible "next" maps in advance. That shouldn't take a long time, though, and file loading is already done asynchronously (XHR).

I imagine this could work:
  1. Determine all possible "next" maps;
  2. Send load requests for the data of each of those maps;
  3. Store/cache the data ready for when the next map transfer happens.
Then on transfer, take the map data from the cache, clear the map cache, then repeat from step 1.
Generally speaking you will not know which map is going to be next, so I think you'd have to load all possible "next" maps in advance. That shouldn't take a long time, though, and file loading is already done asynchronously (XHR).

I imagine this could work:
  1. Determine all possible "next" maps;
  2. Send load requests for the data of each of those maps;
  3. Store/cache the data ready for when the next map transfer happens.
Then on transfer, take the map data from the cache, clear the map cache, then repeat from step 1.

Yes, that is exactly what I had in mind (I am currently storing map x and y in the map name. e.g. Map(0,1) and parsing it out), but I was thinking the file load was taking too long. However, you are correct that it is using XHR, so this shouldn't be causing my performance issue.

I will strip the load process down to the bare bones and start isolating what part of the code is causing the performance issue.

Thank you for your help!

Original thread: https://forums.rpgmakerweb.com/threads/loading-data-across-multiple-frames.146690/