FreezingMoon / AncientBeast

The Turn Based Strategy Game/eSport. Master your beasts! 🐺
https://AncientBeast.com
GNU Affero General Public License v3.0
1.66k stars 571 forks source link

pre-match deferred js loading #1472

Open DreadKnight opened 5 years ago

DreadKnight commented 5 years ago

Having everything bundled if a single huge js file is really bad, as it delays the use of the pre-match screen UI and drops the score of the page (which affects search rankings).

The pre-match screen doesn't contain any game logic or functionality, so it would be great if it could include and only make use of jQuery and jQuery-ui asap (which Cloudflare tends to cache and reuse nicely across different websites afaik), rather than having to wait for phaser-ce along with all the game logic and data to also be loaded (several mb of stuff), which could be deferred and still loaded (pre-cached) from the main menu, so that you'll be able to launch the game asap, speeding up the load. This trick is used by Dota 2, having players dealing with pre-match stuff, like picking lanes, heroes and starting items, while the game assets are being loaded in the background, reducing load time drastically.

Phaser-CE should probably be in its own minified file rather than bundled with the our game logic, for better CloudFlare cache reuse, through its a rather less likely scenario, but we would be dealing with very small amount of js files to load anyway.

DreadKnight commented 5 years ago

This could also speed up the project's build time quite a bit, as it will leave more of the libs untouched.

ktiedt commented 5 years ago

Absolutely right, I was against even committing this initial build this way. Part of the problem is that we also are inlining other resources into the JS as well. It is a horrible approach.