News for hackers. Stuff that matters.
Re:Real-time updates without JavaScript by EgoIncarnate on Tuesday February 06, 2018 @04:02PM (#16319600)
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...
Re:Real-time updates without JavaScript by twiss on Tuesday February 06, 2018 @04:12PM (#16319752)
The 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.

Re:Real-time updates without JavaScript by The_suffocated on Tuesday February 06, 2018 @04:06PM (#16319662)
But what?
Re:Real-time updates without JavaScript by lhorie on Tuesday February 06, 2018 @04:10PM (#16319727)
It breaks when you press `esc`. Either that, or the DOM just keeps growing and hogging memory until the tab eventually becomes unresponsive or crashes
Re:Real-time updates without JavaScript by The_suffocated on Tuesday February 06, 2018 @04:14PM (#16319776)
Thanks, 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?
Re:Real-time updates without JavaScript by lhorie on Tuesday February 06, 2018 @04:17PM (#16319820)
With 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.
Re:Real-time updates without JavaScript by The_suffocated on Tuesday February 06, 2018 @04:28PM (#16319956)
Thanks for the explanation. I'm too green to understand this, but I'll try to learn more about it later.
Re:Real-time updates without JavaScript by wybiral on Tuesday February 06, 2018 @04:37PM (#16320065)
Presumably you'll eventually write something rather than lurking for hours and then it'll refresh.
Re:Real-time updates without JavaScript by lhorie on Tuesday February 06, 2018 @04:46PM (#16320158)
I 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.
Re:Real-time updates without JavaScript by wybiral on Tuesday February 06, 2018 @05:32PM (#16320563)
The spam had nothing to do with not using Javascript. I could easily have added a CAPTCHA or required accounts.
Re:Real-time updates without JavaScript by roywiggins on Tuesday February 06, 2018 @04:39PM (#16320081)
In extremis a <meta refresh> could be used.
Re:Real-time updates without JavaScript by reificator on Tuesday February 06, 2018 @04:49PM (#16320187)
But 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.
Re:Real-time updates without JavaScript by myfonj on Tuesday February 06, 2018 @05:13PM (#16320407)
Not necessarily: browsers are pretty good at keeping form elements state across refreshes nowadays, especially Firefox. Cursor position perhaps, but not text.
Re:Real-time updates without JavaScript by reificator on Tuesday February 06, 2018 @09:52PM (#16321909)
Perhaps, but certainly there will be frustration there. Especially WRT cursor position changing.
Re:Real-time updates without JavaScript by sebazzz on Tuesday February 06, 2018 @05:02PM (#16320321)
My Surface tablet got warmer and warmer on my lap.
Re:Real-time updates without JavaScript by ErunamoJAZZ on Tuesday February 06, 2018 @04:09PM (#16319708)
Page never end to load.