Show HN: My multiplayer custom-engine game that loads in less than a second
Hi. To make my game load quickly, it uses <link rel=preload> on JavaScript resources, smallest scripts first. While the game itself is loading, the server selector's inline JavaScript immediately loads the list of servers from a CDN, surge.sh. The idea is network requests that depend on network requests should load first, because they have the longest chain of roundtrips.<p>It pings a random server in each region to find the nearest region, which is found by finding the server that replies first, since nearer servers are closer. Then it pings all servers in a region to find the number of players. It randomly picks from the server with the two least number of players. Then the JavaScript transparently pre-loads game resources (mockups.json and skillmap.json) by appending a <link rel="preload"> to the <body>. That way, once the game starts, "fetch" will find preloaded resources.<p>80% of players said it was very fun.