5 ms·
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 selec
by crazypython 6y ago
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.
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.
80% of players said it was very fun.
- michaelpb 6y agoLooks like a fun io game, congrats! One day i'll have the time to finish one of my games hahah Also congrats on the fast load time! Slow JS is my biggest peeve about the modern web. My "daily drivers" are all under-powered hardware -- I have not spent more than ~$250 on a computer in like a decade -- which 1) forces me to develop lightweight & quick frontends, and 2) reveals just how awful so many websites are for anyone who isn't using the maxed-out MacBook Pro that the original developer used.
- onion2k 6y agoI test all my frontend code on a $200 Chromebook. It's a really nice way of finding bugs that I'd never have noticed on my main dev machine.
- iforgotpassword 6y agoI want to upvote this multiple times. And we've reached a point where not only web devs should do this. Even the (Linux) open source world starts to move towards bad performance when a decade ago they broadly prided themselves by being not as bloated and slow as all the "Windows crap". Use your own stuff on a middle class machine with a spinning disk from 10 years ago once a week for the whole day to get a baseline. And sure there are exceptions, some programs just need a beefy machine, but many times there are mundane things like fi. a dozen unnecessary redraws of a list that go unnoticed on the latest threadripper with RAID-0 NVMe disks, but make the UI jump and twitch in an irritating way on slower hardware.
- skinkestek 6y ago> Even the (Linux) open source world starts to move towards bad performance when a decade ago they broadly prided themselves by being not as bloated and slow as all the "Windows crap". We've ended up collectively trading availability of applications for performance I'd say because of things like electron. And yes it is a tradeoff. KDE and Linux however is still blazing fast so there's still some[1] speed advantage. [1]: and sometimes, like with git, command line applications and compiling - a whole lot.
- redis_mlc 6y ago> I have not spent more than ~$250 on a computer in like a decade You're fine using the Internet even on netbooks if you disable web fonts and use uBlock Origin. Old computers can't run Docker, which requires VT-x: https://en.wikipedia.org/wiki/X86_virtualization https://en.wikipedia.org/wiki/X86_virtualization
- dom96 6y agoNice! Interesting approach. I'll have to try to replicate this for my game[1] where the loading of some JS scripts is sometimes annoyingly high (in particular for the cookie consent for some reason). > 80% of players said it was very fun. Curious how you got this statistic, do you ask this in-game or did you do a case study with some friends? Btw I just played and found the FPS to be quite low (there was a lot of things firing on me). This was Firefox on Windows. (Edit: tried Chrome and there is a visible difference, so you seem to have a bottleneck on FF) 1 - https://stardust.dev/play https://stardust.dev/play
- crazypython 6y ago> (in particular for the cookie consent for some reason) I suggest making that script async, so it loads after defer scripts, which you should add to your main game scripts. > Curious how you got this statistic, do you ask this in-game or did you do a case study with some friends? With friends and based on online feedback.
- smolder 6y agoLove to see this kind of craftsmanship. It's nice to make things snappy, especially because it broadens the reach to people who don't have the best hardware or connections.
- tobr 6y ago> nearer servers are closer This accurate statement is correct.
- lovelyviking 6y agoVery nice game, but would you add aiming with keys? I have no mouse for instance ... very difficult to win shooting in one direction only :)
- soared 6y agoCool project. Now that you've done the hard work, you need to do the next hard bits - cheating so it seems like it loads even faster. I see the "Loading..." for <1 second - but why do I see it at all? Give me the form to fill out my username first, because that will take me more than a second to type and you can load in the background. Sometimes ux hacks are worth just as much as actually good building blocks.