8 ms·
What is the advantage over just using this: var source = new EventSource('pull?name=one'); source.onmessage = function (event) { document.getElementByI
by bullen 8mo ago
What is the advantage over just using this:
var source = new EventSource('pull?name=one');
source.onmessage = function (event) {
document.getElementById('events').innerHTML += event.data;
};
http://talk.rupy.se/event.html http://talk.rupy.se/event.html
> If you need bi-directional communication, then you should consider using WebSockets instead.
Or you just do a HTTP request?
- adontz 8mo agoHTMX can do much more than just innerHTML swap. https://htmx.org/attributes/hx-swap/ https://htmx.org/attributes/hx-swap/ https://htmx.org/attributes/hx-swap-oob/ https://htmx.org/attributes/hx-swap-oob/ https://htmx.org/attributes/hx-target/ https://htmx.org/attributes/hx-target/
- anamexis 8mo agoEverything HTMX does could be "just" done using JS - this is self-evident. The whole point of HTMX is to enable features like this directly in HTML.
- infamia 8mo agoIf you do that you'll reset browser state with whatever you're replacing. For example things like scroll position, if the user opened an accordion, etc. would all be lost.
- recursivedoubts 8mo agoI mean you're not wrong: end of the day htmx is just some javascript written on top of standard vanilla javascript apis. It tries to handle things in a more html-centric, attributes-driven manner than script-oriented approaches do, but it's nothing too complicated check out fixi for our ultra-minimalist take on the idea: https://github.com/bigskysoftware/fixi https://github.com/bigskysoftware/fixi Or, for extreme minimalisim, htmz, which repurposes iframes for a similar idea: https://leanrada.com/htmz/ https://leanrada.com/htmz/