pagefaultgames / pokerogue

A browser based Pokémon fangame heavily inspired by the roguelite genre.
https://pokerogue.net
GNU Affero General Public License v3.0
4.35k stars 1.75k forks source link

Quick optimization for the website[Feature] #1913

Closed fschatbot closed 1 month ago

fschatbot commented 3 months ago

Is your feature request related to a problem? Please describe. The website was taking way to long to load and was requesting a lot of needed content from the server which can be optimized quickly.

Describe the Features

  1. The first thing is that the main index.js file contains all the translations. This can be removed from the index.js and shifted to another JSON file and then loaded as required. For example, all the English translations go to en.json, Spanish to sp.json, and so on.
  2. Secondly, the website is fetching audio files even if the master volume is set to 0. This can be easily changed by putting a check in the main audio loader/player code
  3. The website isn't sending minified versions of the .json files. This can easily be changed in deployment by just minifying any .json file or whilst serving the JSON files. A major example would the JSON files requested for sprite rendering.

All of the above-mentioned won't be hard to implement and would only a few lines of code to implement. I really like the game but with my bad internet I would highly recommend these changes to reduce the load on both the client and the servers!

flx-sta commented 3 months ago

@fschatbot Would you mind give some sources where possible? e.g. the thing about the translations is correct. If I am correct this would be a sauce: https://www.i18next.com/how-to/add-or-load-translations

torranx commented 3 months ago

I've done some digging on this and I think it's not that easy to implement this because of the state/structure of the codebase right now.

fschatbot commented 3 months ago

@flx-sta It is i18 precisely what I am talking about. In index.js if you search for the term solarPower you can how there are multiple translations for the same thing in index.js itself.

@torranx Whilst it may be true that the codebase may not allow the sharding the index.js for various translations. We can at least implement the other 2 suggestions as they I am sure are not hard to implement 100%. The audio suggestion from my understanding would only require the modification of base-scene.ts and as for the JSON not being minified is definitely something that be fixed.

torranx commented 3 months ago
  1. Audio - this is not as easy as not fetching the audio when the game is on mute, what happens then if the user decides to unmute? the game will crash because it cant find audio (from my understanding). lets not forget that this is made with phaser and it needs initialization.
  2. the JSON being minified is something i agree with
flx-sta commented 1 month ago

3073 - Minify the JSON files is being worked on

flx-sta commented 1 month ago

It’s hard to maintain issues with multiple tasks. I have noted those on my list. If those enhancements are still missing in the future feel free to open another issue