Skip to content
Swizec Teller - a geek with a hatswizec.com

SSR, SSRwR, SSG, CSR, WTFBBQ???

These abbreviations are getting out of hand Friend. It's like a bad interviewer's wet dream.

"Tell me, what is the difference between rehydrated SSR on a gibson supercomputer with 20kilobytes of RAM versus an SSG SPA on a horizontal supercluster with K8s and a11y?"

I don't know, damn it, I use tech to solve problems and make money. Who cares what it's called, we're not 12 year old Star Trek nerds.

Knowing the name of the thing vs understanding the thing

You can know the name of a bird in all the languages of the world and you'll know absolutely nothing about the bird... So let's look at the bird and see what it's doing — that's what counts

Nerds like to forget that you don't know much, if all you know is the name. Especially if you step on a nerve.

Debates rage online and in tech teams bikeshedding on the names of things. Super common with folks who just read a book about it. Once you notice, it's everywhere.

Are you using The Strangler Pattern or are you slowly replacing old functionality with new? 🤔

Names help you move faster as a team. But if you see an interviewer fussing about the names of things, run away.

SSR vs SSG vs SPA vs CSR 🤨

Last week I wrote about server side rendering and server side generation and got it backwards. What I called SSG is SSR and what I called SSR is ... checks notes ... CSRwPR

The whole thing is a spectrum. From full server rendering to full client side rendering.

And as taxonomies always are, that table is subtly wrong.

Gatsby pre-renders whole pages not just their shell and they work without JavaScript, but don't remove it. NextJS can do full CSR, but also SSR with rehydration or pre-rendered CSR.

Never trust a taxonomy my friend.

Which should you use?

On ep18 of CodeWithSwiz 👇 we dug into all this and found the important factor.

If your page needs data, you're gonna have to get that data. The only difference is when.

Pages rendered in the browser suffer from the loading spinner effect. Open page, wait for data to load.

Clients do the waiting, and your bandwidth and server use is low – mostly data and lots of small requests. Sucks on airplane wifi with high latency.

Pages rendered on the server suffer from the full page reload problem. You click a link and get a whole new page.

No requests on the client, but you're transferring all the HTML every time. Even the header and footer that always stay the same. Takes up lots of server resources and sucks on networks with low bandwidth.

Steps between extremes

You can't solve this problem. You can smudge the cost around.

With static site generators like Gatsby, you make those API requests at deploy time. Creates slow deploys and fantastically speedy pages.

No data fetching on the server or the client. Pure speed.

But if each page takes 2 seconds to generate and you're deploying 1000 ... that's 33 minutes. 😅

With hybrids like NextJS, you have a choice.

Use SSR – server side rendering – and you're doing those 2 seconds worth of requests on every page load for every user. Maybe that's okay, maybe it isn't.

Use SSG – server side generation – and you're doing those 2 seconds worth of requests on some page loads for some of the users. It's a cache.

First user hits your page: 2 second load. Second user hits the cache: blazing speed. Wait a few hours, next user gets 2 second load, page left the cache.

Maybe that's okay, maybe it isn't.

Frameworks like Ruby on Rails Turbolinks and (I think) RemixRun take a different approach still. Each request gets full HTML, but for a specific <div> on the page.

Like loading your page in fragments.

How do you pick then?

You know the performance characteristics for your project. There is no solution.

Same page takes 28ms to load with Gatsby, 2s with NextJS's SSR. Yes I used the wrong words in my tweet.

Is that okay? 🤷‍♂️

Do you care about fast initial loads, useful initial loads, average performance, fastest performance, slowest performance? Depends what you're building.

And remember, there is no cake, only tradeoffs.

Cheers,
~Swizec

PS: we're launching a big bundle tomorrow and courses inside talk about this in more detail

Did you enjoy this article?

Published on November 24th, 2020 in nextjs, gatsby, technical

Learned something new?
Want to become a high value JavaScript expert?

Here's how it works 👇

Leave your email and I'll send you an Interactive Modern JavaScript Cheatsheet 📖right away. After that you'll get thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over my 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

Start with an interactive cheatsheet 📖

Then get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career.

"Man, love your simple writing! Yours is the only email I open from marketers and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"

~ Ashish Kumar

Join over 10,000 engineers just like you already improving their careers with my letters, workshops, courses, and talks. ✌️

Have a burning question that you think I can answer? I don't have all of the answers, but I have some! Hit me up on twitter or book a 30min ama for in-depth help.

Ready to Stop copy pasting D3 examples and create data visualizations of your own?  Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization

Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.

Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev

Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️