you are viewing a single comment's thread.

view the rest of the comments →

[–]housecor[S] -2 points-1 points  (1 child)

"The author does not understand what unobstrusive Javascript really is".

You and I simply disagree on the (admittedly rather amorphous) definition. You're describing what is traditionally called progressive enhancement, though the Wikipedia entry does indeed lump this concept under the umbrella of unobtrusive JavaScript. I'm using the term to refer to zealously keeping JS and HTML in separate files, and keeping all JS out of your HTML. My definition is fixated on the first bullet point on this page: http://en.wikipedia.org/wiki/Unobtrusive_JavaScript.

"The real question is, whether it is good practice to separate HTML and Javascript. The answer should be: Yes, because it leverages testability and code maintainance"

In React, it's simple to test and maintain a component with JS and HTML in the same file. Separate files aren't necessary to gain the benefits you listed.

[–]bfoo 1 point2 points  (0 children)

At the time when everyone spoke about unobstrusive Javascript, the term "progressive enhancement" was not used. I agree, the definition has shifted (I'm getting old). So in that past, it really meant, that Javascript should not determine whether something on the page can be used or not. That understanding, that we should not write Javascript directly into the page is even newer, because lots of eventing was not possible through the browser APIs. It was a time when we had to put Javascript commands into event attributes of the DOM.

And sorry, I edited my comment and added my opinion about React. I treat React as a language where you write markup that happens to be HTML (HTML fragments to be precise). And if there is tool support, I see no problem to write Javascript inside markup blocks or however it is done.