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.

    Obed Parlapiano avatarObed Parlapiano@ObedParla
    @seanconnollydev @Swizec @leeerob @flybayer Lol I love those acronyms. I deeply dislike the whole SSR, SSG, SHFVahGssSSSS acronyms that we have nowadays, and different products meaning different things with them (worse because they're both right!)

    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.

    Swizec Teller back on his Be An Expert bullshit avatarSwizec Teller back on his Be An Expert bullshit@Swizec
    Interesting discovery today:

    #NextJS SSG page: 2 second load
    #Gatsby SSR page: 28ms load

    Same page.

    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, React, technical,

    Learned something new? Want to become a React expert?

    Learning from tutorials is easy. You follow some steps, learn a smol lesson, and feel like you got dis πŸ’ͺ

    Then comes the interview, a real world problem, or a question from the boss. Your mind goes blank. Shit, how does this work again ...

    Happens to everyone. Building is harder than recognizing and the real world is a mess! Nothing fits in neat little boxes you learned about in tutorials.

    That's where my emails come in – lessons from experience. Building production software :)

    Leave your email and get the React email Series - a series of curated essays on building with React. Borne from experience, seasoned with over 12+ years of hands-on practice building the engineering side of growing SaaS companies.

    Get Curated React Essays

    Get a series of curated essays on React. Lessons and insights from building software for production. No bullshit.

    Join 15,883+ engineers learning lessons from my "raw and honest from the heart" emails.

    ⭐️⭐️⭐️⭐️✨
    4.5 stars average rating

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help πŸ‘‰ swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers πŸ‘‰ ServerlessHandbook.dev

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

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

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

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    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 ❀️

    Created by Swizec with ❀️