5 ms·
You can hack it and optimistically render the data you know about because your client created it - on the frontend, at no additional cost.
by jokethrowaway 3y ago
You can hack it and optimistically render the data you know about because your client created it - on the frontend, at no additional cost.
- hot_gril 3y agoThis is usually what I do. Don't even want to wait for an HTTP roundtrip for some of these, e.g. "liking" a post should fill in the heart icon or whatever instantly. One famous example of this going to far: Mac Mail app used to play a whoosh sound when your email is actually sent. They changed it to whoosh instantly no matter what. Given how often an email might fail to send or get delayed, this meant an actually useful indication of "great, your thing was sent, you can close your laptop now" was rendered useless.
- ceejayoz 3y ago> Don't even want to wait for an HTTP roundtrip for some of these, e.g. "liking" a post should fill in the heart icon or whatever instantly. HN does this, and on slow days, about half of my upvotes don't go through.
- wizofaus 3y agoYou actually check your list of upvoted comments?
- ceejayoz 3y agoNo, I just notice it when I come back to the thread later in the day and a bunch of comments I know I upvoted are back to normal.
- hot_gril 3y agoMessaging apps often have a checkmark to indicate the message actually went to the server, and maybe another checkmark to indicate it was received on the other end. Maybe HN needs an icon indicating that your vote went through.
- newaccount74 3y agoMake the arrows grey to indicate the click registered, make them disappear to indicate the server successfully registered the vote?
- hot_gril 3y agoYeah, it's easy enough that I was able to do it in the web inspector in a minute (artificial 1s network delay added): https://s11.gifyu.com/images/ScPMI.gif https://s11.gifyu.com/images/ScPMI.gif
- sitzkrieg 3y agoyea but does hn have any client side js?
- codetrotter 3y agoYeah, a very small amount so that clicking the upvote button does not need to reload the whole page
- hot_gril 3y agoCan confirm, HN relies on client-side JS for voting and collapsing, but view/post/edit/delete don't need it.
- sitzkrieg 3y agomakes sense, thanks for the clarification yall
- bmacho 3y agoUpvoting does work javascript disabled, it upvotes and reloads the page. It approximately keeps your position by jumping the message anchor.
- codetrotter 3y agoI know it works with js disabled as well. But with js enabled they send just the upvote instead of reloading the whole page. Saving network traffic. Unfortunately the js used is very minimal. And if the upvote fails, there is no graphical indication that it failed to upvote.
- deleted 3y ago[deleted]