2018-01-03 00:26

Why Stimulus has it right

1/4 Yesterday I tweeted (https://t.co/krCNWpdjEH) about Stimulus. Someone objected to my remark that behavior belongs in HTML, not in JS. I'll explain why I think Stimulus has it right:

Source

2/4 In the past we used to embed styles in HTML elements, today we use IDs and classes to apply CSS styles. So: the web agrees that style behavior belongs in HTML. Note the word behavior, the actual style data resides in a separate CSS declaration (included or embedded).

Source

3/4 In the past we embedded JS code in HTML elements (onclick="...", href="javascript:..."). Today we use IDs, classes and data attributes to associate HTML elements with code residing in a separate JS declaration. See where I am heading?

Source

4/4 But suddenly with the advent of React etc we started to move HTML elements into JS code. Stimulus, KnockoutKS etc. therefor take a much better approach: behavior is defined in HTML, and only codes resides in JS. Symmetrical and logical.

Source

§ Permalink

ξ Comments? Kudos? Find me on Twitter

.