4 ms·
I guess it could be useful for simple DOM manipulation. The issue with it is, despite how great co-locality of concerns is, is that it can't EVER be separated.
by gnrlst 5y ago
I guess it could be useful for simple DOM manipulation. The issue with it is, despite how great co-locality of concerns is, is that it can't EVER be separated. So I would use something like this if I wasn't using any framework at all. As soon as you use a framework (e.g. svelte/react/vue), the need for manual jQuery/dom manipulation drops to near 0.
- Cthulhu_ 5y ago'guess' indeed, it probably doesn't take long to run into a situation where you have to go back to regular JS. I'm confident the examples given can be simplified as well. The vanilla JS and jQuery examples are not equivalent for example, the vanilla one is (intentionally?) inline JS whereas the jquery one separates it out. It also doesn't use ES6 arrow functions (neither vanilla nor native), which would remove the need to rebind `this` to `self`. The vanilla one also sets style via JS, which isn't how you should do things. Transitions can be set in CSS beforehand. The one used sets the animation to 'all' properties as well, instead of just 'opacity' which is the only property changed. TL;DR the article is making vanilla look more difficult than it is. The jquery example seems lifted off of Stack Overflow.
- mrozbarry 5y agoI think this should expose something like `_hyperscript.on(domElementHere, 'your hyperscript string')` and that could resolve the co-locality concern.
- recursivedoubts 5y agowe are working on supporting _hs files and you can write event handlers against other elements: on click from #some-btn log 'The button was clicked' end However, we really lean towards directly embedding the scripts on HTML elements for Locality of Behaviour https://htmx.org/essays/locality-of-behaviour/ https://htmx.org/essays/locality-of-behaviour/
- dsego 5y agoYou wouldn't use a framework like react/vue with this. It is a companion project of htmx (1) which takes a different approach than your typical JS framework. There is a recent JS Party podcast (2) with the author if you want to learn more and have a better understanding of the motivation behind these approaches. 1 https://htmx.org/ https://htmx.org/ 2 https://www.youtube.com/watch?v=hJdxR6qoUOE https://www.youtube.com/watch?v=hJdxR6qoUOE
- brianzelip 5y ago> recent JS Party podcast (2) See also https://changelog.com/jsparty/171 https://changelog.com/jsparty/171