5 ms·
WTF? why any JS at all for something that's pure content?
by jordache 9y ago
WTF? why any JS at all for something that's pure content?
- na85 9y agoHistory repeats itself. This is just like flash sites back in the 90s.
- TomMarius 9y agoIt has no benefit on the client itself, but in this (server-rendered) case, you can think of it as improved PHP/Ruby/....
- josteink 9y agoThe 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.
- TomMarius 9y agoBecause 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.
- jimktrains2 9y agoSeems like it'd be easier to just use the templates already there for the content on the server, instead of building an additional application.
- jordache 9y agoi 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?
- josteink 9y agoSimply 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).
- TomMarius 9y agoJosteink 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.
- dom0 9y agoBecause this site is clearly in need of 250 KB surveillance JavaScript. So even this "plain text" site still transfers ~98 % bloat and just ~2 % content.
- AndrewCHM 9y agotransfer is different from filesize its more around 90% JS, 10% content After the first page load (with scripts cached) its around 87% content (unfortunately they don't seem to be caching CSS)