5 ms·
TLDR: It's a basic chat app. It's using a streaming http connection and css "::before" to reverse the order of new output, so it doesn't need javascript. Intere
by EgoIncarnate 9y ago
TLDR: It's a basic chat app. It's using a streaming http connection and css "::before" to reverse the order of new output, so it doesn't need javascript. Interesting hack, but...
- The_suffocated 9y agoBut what?
- ErunamoJAZZ 9y agoPage never end to load.
- lhorie 9y agoIt breaks when you press `esc`. Either that, or the DOM just keeps growing and hogging memory until the tab eventually becomes unresponsive or crashes
- The_suffocated 9y agoThanks, but isn't this the same if you use a virtual DOM? Is Mithril not prone to this problem if you keep adding stuffs to the list?
- lhorie 9y agoWith javascript you can keep an EventSource connection open (which is immune to the `esc` thing), and you can prune the DOM and let the browser GC.
- The_suffocated 9y agoThanks for the explanation. I'm too green to understand this, but I'll try to learn more about it later.
- wybiral 9y agoPresumably you'll eventually write something rather than lurking for hours and then it'll refresh.
- roywiggins 9y agoIn extremis a <meta refresh> could be used.
- reificator 9y agoBut then if you refresh every ten minutes or so, and I just happen to be finally responding after that long, I'm going to lose what I'm typing.
- myfonj 9y agoNot necessarily: browsers are pretty good at keeping form elements state across refreshes nowadays, especially Firefox. Cursor position perhaps, but not text.
- reificator 9y agoPerhaps, but certainly there will be frustration there. Especially WRT cursor position changing.
- lhorie 9y agoI mean, sure, it works just fine if people refrain from doing certain arbitrary things (such as the scripted spamming that's happening as I write this), but that's why the grandparent comment said it was a hack and not a trick that one might want to attempt in production.
- wybiral 9y agoThe spam had nothing to do with not using Javascript. I could easily have added a CAPTCHA or required accounts.
- sebazzz 9y agoMy Surface tablet got warmer and warmer on my lap.
- twiss 9y agoThe CSS to reverse the order is: main { display: flex; flex-direction: column-reverse; } The many ::before <style>s are used to update the connection count. If you like these kinds of tricks, there's also an "order" CSS property, which lets you give elements any arbitrary order you like (by giving each element a numeric index). This can be useful for implementing sorting functionality, for example.