WFRP4e-FoundryVTT icon indicating copy to clipboard operation
WFRP4e-FoundryVTT copied to clipboard

Reduce number of HTTP request caused by .txt files when loading a world

Open grz0 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. When starting a game world, multiple txt files used by the name generator are being loaded. In the case of a freshly created world with core, altdorf, rnhd and starter set modules enabled, more than 10% of HTTP requests are caused by these txt files: image

Describe the solution you'd like Consolidate multiple txt files into JSON files or load them when needed, not during world initialisation.

grz0 avatar Jul 23 '23 00:07 grz0

I don't think consolidating them is that important. I would suggest that loading them on demand (when opening the character creator) would be better.

But I think the best way to change this would be to do these two things:

  1. Change the NameGenWfrp._loadNames(); call from init hook to ready hook.
  2. Change the NameGenWfrp._loadNames(); method from synchronous to asynchronous.

So it would still be already preloaded in case someone wants to create a character and the app would open without the lag, but it would not load them synchronously on init, which is what can slow down loading.

Unless I'm mistaken how Foundry handles hooks. In that case disregard my comment.

Forien avatar Jul 23 '23 05:07 Forien