News for hackers. Stuff that matters.
Re:Text-only CNN by josteink on Sunday September 10, 2017 @07:27AM (#15211748)
The question wasn't why anyone was using Javascript on the server.

The question was why a pure-text non-interactive website needs any javascript at all.

Re:Text-only CNN by TomMarius on Sunday September 10, 2017 @08:10AM (#15211872)
Because when you're treating React as a templating language, it's easier to let it run on the client side during development and add server rendering later.
Re:Text-only CNN by jimktrains2 on Sunday September 10, 2017 @09:36AM (#15212166)
Seems like it'd be easier to just use the templates already there for the content on the server, instead of building an additional application.
Re:Text-only CNN by jordache on Sunday September 10, 2017 @12:35PM (#15212922)
i don't know react. Can you elaborate what you mean using React as a templating language? Are you saying react can be used sans any business logic and purely for template interpolation?
Re:Text-only CNN by josteink on Sunday September 10, 2017 @03:23PM (#15213825)
Simply put, React lets you do two things:

* Generate a HTML/DOM based on a template and data.

* Lets you efficiently update that DOM based on updates to the data and/or model (this is it's killer feature).

But if you're just going to do the first thing (generate a HTML/DOM), you don't need most of React's feature set, and you certainly don't need to push heavy JS onto the client.

For those cases, a much better approach (for both clients and SEO) is to just pre-render the DOM/HTML server-side and serve that without any need for any javascript client-side (which is what the similarly named module "Preact" does).

Re:Text-only CNN by TomMarius on Sunday September 10, 2017 @04:05PM (#15214059)
Josteink said it excellently, my addition is that React itself is a view library that lets you update DOM easily based on some data, and the data (and the logic behind it) can be and often are completely separated from React components themselves.