Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKieran Barker
15,028 PointsDoesn't this violate the principle of unobtrusive JavaScript?
Previous JavaScript courses taught me that any JavaScript I write should be unobtrusive, meaning that critical parts of the page should not rely on it. Otherwise, on a slow network connection, or with JavaScript disabled, these parts of the page would never be seen.
If we're using React to inject key markup into the page... Doesn't it go directly against the principle of UNOBTRUSIVE JavaScript?
2 Answers
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsServer side rendering is a way to get around this problem, so at least the first page load is not dependent on JavaScript. But you still might need JavaScript to support other interactions after the page loads.
Unobtrusive JavaScript isn't always possible or necessary. If you know that your users could be using an older browser, or using something like the opera mini browser, you should take this into consideration. The market share of devices without JavaScript is shrinking as browsers get upgraded and hardware devices and infrastructure improve in the developing world. And in a lot of cases, you know who your users are and what browsers they're likely to use. Also, a lot of interactive experiences you really can't do without JavaScript. So the best thing you could do with no JavaScript would be some fallback page that says "sorry, you can't use this feature".
Axel Perossa
13,930 PointsIt really does depend on your particular app or site, but it's a heavily opinionated matter. Brendan's response makes it seem like you always need javascript nowadays. However many people don't agree with that and believe that unobtrusive and progressive js is still totally relevant and preferable.
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsThat is true. You probably wouldn't want to use React in that case.