3 ms·
Can someone explain the trend of mixing HTML and JS code that has been increasing lately? We fought for years to get away from that so I'm curious to know what
by Zelphyr 8y ago
Can someone explain the trend of mixing HTML and JS code that has been increasing lately? We fought for years to get away from that so I'm curious to know what happened to make people think it was suddenly a good idea. I'm not suggesting it's not or that it is permanently bad. I'd simply like to know why it's good after being considered a bad practice for so long?
- prezjordan 8y agoWhen building certain applications, it turns out those concerns aren't really separate! It helps a lot to colocate the markup and the code that generates/modifies it.
- MentallyRetired 8y agoI fought hard for that as well among friends and colleagues. Here's my take on it: * I view vue/react/etc as a sort of polyfill for webcomponents. * I also look at JSX and Vue templating as just that -- programmatic templates that serve as a guideline for the HTML they create. That's what lets me sleep at night.
- dcre 8y agoLike the other commenter said, people realized that separate languages does not necessarily mean separate concerns. Once you start modifying HTML from JS enough, you start to realize the JS counts as view logic just like the template does. So the division of concerns changed from View (HTML template)/Controller (JS) to View (dynamic, written in JS)/Data (also likely JS). The thing is, people were effectively writing HTML in JS before too, it's just that it looked like `el.style.color = 'red'` instead of `<div style={{color: 'red'}}>`.