Rendering on the Web
developers.google.com
developers.google.com
Some might even say it is better to mostly ship HTML with minimal JS.
ducks
It's sad how most websites these days are fully-featured web applications. Take this blog page by Google. A simple web page with some pictures loading over 300kB of Javascript libraries and tooling. And this isn't even an exception. It's sad, really, and a waste of readers' bandwidth.
The problem I find is usually misaligned incentives. When you go to BuzzFeed you just want to read an article, but BuzzFeed wants to track you and sell you ads. It's not in their best interest to keep it simple.
If you're not going to, don't tell me how to work with code I gotta work with.
Can we just agree to let this meme die? React and vue didn't appear because developers wanted bloat.
If you want to reduce bloat, take that to corporate greedy actors stuffing pages with tracking and don't ever touch tools that make my life easier.
Spring, JEE, ASP.NET, Rails, Django,...
Same question. Who's going to write all those 'components' wrapping libraries for each of those when everyone has already moved on to react or vue? Some disgruntled retrograde? Am I supposed to waste time on it so that you can bask in the glory of 'pure html and js'?
In a few years the React/Vue fad will be gone, while HTML/CSS/VanilaJS will still be around.
We are the ones not wasting time learning fad of the day stacks.
Certainly. However, something even better will replace it and you guys will moan about it again. It only hurts yourself if you refuse to learn.
Coffeescript, Dart, AngularJS, Dojo, MooTools, Prototype, Bower,...
So much time I saved keeping focused on SSR frameworks, alongside VanillaJS.
I used to look down on something like Next.js/Nuxt.js [1] for simple (and advanced) websites until I used it and I'm 100% convinced it's the future of web development. Where most of the content is built with components but pre-rendered server-side and the JS loads to 'hydrate' the interface with interactive elements. I've stopped using heavy frameworks like Phoenix as a result and switching to simpler backends APIs written in Rust/Ruby/etc with Vue SRR handling the full frontend.
Combined with treeshaking, chunked JS via webpack (which automatically only renders tiny .js files on-demand based on what components the page/route needs), purgeCSS which removes all unused CSS, PWA/critical inlined CSS tools, and other easy-to-use optimizations you can have a fully feature-rich JS site with SEO-friendly HTML pages and very fast page loads.
We're just seeing the beginning of Vue/React and it's going to improve the web from the ills of the past, not make it worse. Better performance and more importantly high-quality well composed codebases, plus TypeScript which helps JS applications scale in size while keeping them sane.
Does my text only newspaper article really need all this crap? Like, it's text, with maybe one image or two. Just give me the damn text and cut out the cruft.
Why are browsers now competing with reader modes? We're sending a bunch of data just to have the browser remove it. Just don't send it to begin with!
"Consider whether static rendering or server rendering can get you 90% of the way there. It's perfectly okay to mostly ship HTML with minimal JS to get an experience interactive."
In other words, just serve some HTML so your users can read your content.
On the other hand, your newspaper writers still need to get paid and unless you're a subscriber, that means ads and cruft on your page for ads.
There is no reason why the following MUST be done client-side:
var label = new Label();
var result = await server.getResult();
label.setText(label);
It was this that led me to invent this for one of my own products.Initially, I had thought server-side React would do this, but apparently it's only for first-load.
raises the question. Sorry, it's a pet peeve.
Petitio principii as the conclusion is a restatement of the premise.
Also it's a rant, not a formal logical argument. Go outside, pet a dog, drink a nice beer, stop wasting your time correcting modern vernacular.
I really don't think that anyone who's been in web dev for more than a couple years still disagrees with the above points.
Take addons.mozilla.org. It's a simple, tiny website with a list of browser addons and a button to download each one. Perfect fit for server-rendered HTML, right? Nah, front-end developers rewrote it in React. [1]
Or blogs. Blogs are just a collection of text pages with occasional images and links. Surely you should use static HTML for those, right? Well, okay, but only for the initial page load; after that, make sure you let React take over so it can "improve" your page navigation. [2]
[1] https://blog.mozilla.org/addons/2017/10/25/test-new-look-add...
[2] https://www.gatsbyjs.org/blog/2017-07-19-creating-a-blog-wit...
1. The Back button had a noticable half-second lag.
2. When I temporarily lost connection and a link I clicked was taking a long time to load, I wasn't given the option to stop loading it like I am when I click a normal link.
I tried disabling JavaScript like a sibling comment suggested, and the website was indeed faster and still flicker-free. (Where do front-end devs get this idea that you need tons of JavaScript to do flicker-free page navigation? Have they never used Hacker News?) But then I wasn't able to see the interactive code examples on the homepage, because those genuinely needed JS to work.
This is because disabling JavaScript is an all-or-nothing proposition. There's no "throw out bathwater but not baby" button or "allow JavaScript only for things it should actually be used for, and not clumsily reimplementing browser features while forgetting half the edge-cases" toggle-switch.
Yes, instant page navigation without flickering is better than the alternative - instant being what you get from reloading a static HTML page, alternative being React.
Seriously, fetching, parsing and displaying a tiny bit of HTML is fast. As fast or faster than the React virtual DOM shenanigans, once you account for the computational load the framework adds on top of your simple page.
If I can make it easier for me and anyone working with my site in the future by sacrificing 50-150 KB then I will take that deal any day of the week. That is what abstractions are for. That is why we do not work in byte-code. We pay for convenience in clock-cycles and disk space.
HTML and CSS are not bytecode. They're high-level abstractions, hiding a very complex renderer underneath. Sometimes you need to build another tower of abstractions when this doesn't suffice - like when you're trying to build an application with complex GUI in the browser and you need an adapter between DOM and a more suitable GUI pattern. But displaying text and images communicating a message is not one of those cases.
ALL (all) of the problems they face are either self-inflicted or due to other web developers, such as those who design web advertisements or bloated JavaScript libraries. The problems with sending multiple simultaneous streams to a browser are due to web developers deciding to design a web page with hundreds of individual files to be downloaded. Rendering times are long because of the complexity that today's sites are built to attain.
I can view simple sites EXTREMELY quickly today -- that is to say, sites that designers have not "improved" to the point that the site is no longer worth visiting. A simple page shows me what I want to see, and doesn't take a designer 400 hours to come up with.
All of today's problems on the web are due to web developers.
I'll fight and die on this hill, and no amount of downvotes will change my mind about this in the slightest.
I have the scars to prove it... currently dying on said hill.
I don't think anyone would fight you on that.
Not sure if we're on same boat here :). By rendered twice I mean:
Let's imagine we use React and some store management like redux.
1. Visit some SSR rendered site. Browser receives html (which represents some initial state of an app - rendered by the server)
2. Browser fetches some json representing initial state (hydration). It's the same state that server used for rendering html.
3. State atom was null in step 1. and changed to some initial state in step 2, which basically means full rerender (second) of an app.
For those here who use other systems like DuckDuckGo that makes a difference. I really started to notice this when I visited some sites (not apps) via the Internet Archive to get old versions and found things broken.
> Streaming server rendering allows you to send HTML in chunks that the browser can progressively render as it's received.
Hasn't PHP done this by default since, like, forever?
...but last time i checked PHP itself was a templating system. What changed?
All of these features and more have to be implemented as a third party framework for PHP to be effective as a templating system, which is why such systems exist.
Merely echoing HTML strings and wrapping variables in htmlspecialchars() does not a "templating system" make. If it did, then every programming language would also be a templating system as long as it could output a string of characters to the necessary port.
It has been a very very long time since i used PHP for anything serious (or did any web programming at all) but to me that sounds like templates. Perhaps you are referring to something else with the word "template"?
Because PHP, natively, doesn't provide the features that a modern template system needs to be safe, scalable or productive. PHP doesn't recognize HTML or XML as a type, or a "template" as a thing, automatically escape user supplied data (correctly, based on context) or correctly deduce content-type headers or route requests or any number of things one expects of a modern framework or templates. As a PHP application grows in complexity, you will, inevitably, find yourself reinventing frameworks. So might as well just use one that's already been proven in the wild and optimized.
All PHP has is string concatenation. It's "templating system" is blind string concatenation - that's it.
That's a fake, not the uncanny valley
Nah
It is perhaps possible that google indexed it from a previous version that did have html, or they are using a sitemap.
(I've just joined the project, and I intend to get them set up with proper SSR soon.)
It's that easy - just one liner to use it in ExpressJS and a server side template system.
Facebook indexes many sites themself for link preview functionality. Preview images, page title, description are all derived from open graph tags.
Can somebody shed some light on this?
For Hacker News, "Server Rendering" is taking the top 25 stories, creating a large string containing all the HTML tags, then serializing that to a byte stream.
A hypothetical "Client Rendering" alternative to HN might be downloading a JSON chunk containing the data about the top stories, then using a JavaScript framework to create DOM nodes in the user's browser that create the same document client-side.
Reduces from 1.2 MB to around 500 KB.
I'm sounding like my grandpa, but... back in my day, things were fast, simple and they worked Now we got this huge mess of technology just so we can track users, sell ads and annoy our site visitors?
[1]: https://jeffy.info/2017/01/24/offline-first-for-your-templat...
The page also received a "Redirection error" on https://stats.g.doubleclick.net/r/collect and https://www.google-analytics.com/r/collect
301 and 302 redirects are also returning a redirection error.
What does "DX" stand for here?
(I also do find this one to be not very well copy-edited/written).
a) From the way your comment is written, it's pretty clear that you actually just want to say what's between the brackets in your second comment. It comes accros as passive aggressive and doesn't contribute anything.
b) The page mentions who have written this article. The names, positions at Google and pictures are all there.