Professional web developer and hobbyist programmer from the Welsh Marches. I'm particularly interested in performance, accessibility, and reducing carbon emissions from software.
Modern solutions like SPA (Single Page Applications) will be more efficient in new cases since you will make fewer calls to the server and the code is cleaner and nicer.
My personal experience has generally been that SPAs are almost always less efficient. A traditional website renders content on the server side and sends that to the client as HTML, a language it can parse and render natively and has had decades' worth of performance optimisations to process.
SPAs, on the other hand, first have to send a (typically large) JavaScript file to the client that must be parsed and executed, just to manage things like hydrating content and page navigation that the browser does natively. Any content is then sent as JSON, a language that has to be offloaded to JS to be parsed, before the page is built by the client.
A good rule of thumb for performance (and carbon emissions, as the two often go hand in hand) is to use browser native functionality wherever possible. Endlessly reinventing the wheel for the sake of perceived developer convenience is rarely better for performance. There are, of course, web applications that do work better as an SPA, but it's a mistake to try and build traditional websites this way in the belief it will improve their performance.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
TLDR (lol) but anything that's client code has two big measurements:
The size of the build
The client's device
To deal with the former make sure you run through a bundler adequately configured to minify your code, make sure the server has the compression enabled and so on.
The later depends on how efficient the device running the site is, E.g. a macbook M2 will waste way less energy than a macbook i9 to load the same website.
Of course, if you go the SSG way you'll find benefits in both 😁
They are good topics, but here we're coming to a couple of things, can you modify your server? What if you cannot? I see it from the final users' perspective, they might have hired a hosting for X period of time, and they can only upload their stuff. They have no control over their infrastructure. In this case, you cannot create a better cache since you rely on your provider. Indeed, you can always change providers, but that means to reconfigure everything. I don't think it's the right way to go.
Where do people run your website? I'd say most of them expect to run them from their phones. So, it will be a similar case to the MacBook M2, but similarly, you can upload considerable images, and the result will be that your website is heavy and slow, increasing its carbon footprint.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
I mean that there's correlation here, if everybody uses more efficient devices and everybody tries and reduces the size and computational complexity of the software as much as possible, we'll reach the peak in that subject.
PD: even if you cannot modify your server because you got a shared hosting (which accounts for 37.64% of the hosting market share as per demandSage statistics) you can use an external service to cache your statics (a.k.a. scripts, images, videos, html files...) e.g. Cloudflare
Do you have any tutorial on how to upload the files only to Cloudflare? I was able to create one, but I was able only to move only my entire website, not only the scripts or images.
Tech Lead/Team Lead. Senior WebDev.
Intermediate Grade on Computer Systems-
High Grade on Web Application Development-
MBA (+Marketing+HHRR).
Studied a bit of law, economics and design
Location
Spain
Education
Higher Level Education Certificate on Web Application Development
You don't need to "move" your files into it.
You can have the website somewhere else and configure your DNS so it is Cloudflare the one answering the requests to your website. Cloudflare will then answer the request with the most recent cached version. It will handle the cache automatically for the most part.
It's an interesting thought, but what if your client only has an S3? I have a friend who faced that limitation. How do you deal with it? I'd like to know your thoughts.
SSRs are an amazing solution when you have your own hosting or have your own server, cluster, etc., which involves certain costs that not everyone wants to pay if they were considered in the beginning. That's why, I focused on what I could fix without moving to other providers or solutions.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My personal experience has generally been that SPAs are almost always less efficient. A traditional website renders content on the server side and sends that to the client as HTML, a language it can parse and render natively and has had decades' worth of performance optimisations to process.
SPAs, on the other hand, first have to send a (typically large) JavaScript file to the client that must be parsed and executed, just to manage things like hydrating content and page navigation that the browser does natively. Any content is then sent as JSON, a language that has to be offloaded to JS to be parsed, before the page is built by the client.
A good rule of thumb for performance (and carbon emissions, as the two often go hand in hand) is to use browser native functionality wherever possible. Endlessly reinventing the wheel for the sake of perceived developer convenience is rarely better for performance. There are, of course, web applications that do work better as an SPA, but it's a mistake to try and build traditional websites this way in the belief it will improve their performance.
There's a guideline for this in the currently draft W3C Web Sustainability Guidelines: 3.23 Take Advantage of Native Features
TLDR (lol) but anything that's client code has two big measurements:
To deal with the former make sure you run through a bundler adequately configured to minify your code, make sure the server has the compression enabled and so on.
The later depends on how efficient the device running the site is, E.g. a macbook M2 will waste way less energy than a macbook i9 to load the same website.
Of course, if you go the SSG way you'll find benefits in both 😁
They are good topics, but here we're coming to a couple of things, can you modify your server? What if you cannot? I see it from the final users' perspective, they might have hired a hosting for X period of time, and they can only upload their stuff. They have no control over their infrastructure. In this case, you cannot create a better cache since you rely on your provider. Indeed, you can always change providers, but that means to reconfigure everything. I don't think it's the right way to go.
Where do people run your website? I'd say most of them expect to run them from their phones. So, it will be a similar case to the MacBook M2, but similarly, you can upload considerable images, and the result will be that your website is heavy and slow, increasing its carbon footprint.
I mean that there's correlation here, if everybody uses more efficient devices and everybody tries and reduces the size and computational complexity of the software as much as possible, we'll reach the peak in that subject.
PD: even if you cannot modify your server because you got a shared hosting (which accounts for 37.64% of the hosting market share as per demandSage statistics) you can use an external service to cache your statics (a.k.a. scripts, images, videos, html files...) e.g. Cloudflare
Do you have any tutorial on how to upload the files only to Cloudflare? I was able to create one, but I was able only to move only my entire website, not only the scripts or images.
You don't need to "move" your files into it.
You can have the website somewhere else and configure your DNS so it is Cloudflare the one answering the requests to your website. Cloudflare will then answer the request with the most recent cached version. It will handle the cache automatically for the most part.
Learn more here 😁
It's an interesting thought, but what if your client only has an S3? I have a friend who faced that limitation. How do you deal with it? I'd like to know your thoughts.
SSRs are an amazing solution when you have your own hosting or have your own server, cluster, etc., which involves certain costs that not everyone wants to pay if they were considered in the beginning. That's why, I focused on what I could fix without moving to other providers or solutions.