4 ms·
This doesn't really resonate with me. It feels like the author's main point boils down to the fact that the only currently (officially) supported way to have cu
by ericyd 3y ago
This doesn't really resonate with me. It feels like the author's main point boils down to the fact that the only currently (officially) supported way to have custom attributes in HTML is with data-* attributes. I guess that's a fine opinion to have, but their example in the conclusion really doesn't look very different to me than if the same code was written with `data-alert data-message="..."`. One big reason I like using javascript for behavior is that it's an actual programming language, so I get all the benefits of things like modules and variables. Its reasonable to argue that more custom attributes should be used vs. lots of verbose JS, but that's what data attributes are, I don't see how 5 characters is hurting us that badly. The author criticizes data attributes for being implicitly focused on data rather than behavior, but I'd argue the author's own final example is also defining data rather than behavior: adding an "alert" attribute is a piece of data that indicates the button will show an alert on click (a behavior that the author adds with javascript) and the "message" attribute indicates the message that will be shown (inherently a piece of data IMO). I must have missed something because I found this article entirely unconvincing.