Exploring Service Workers

The Case for Service Workers

Kyle Simpson

Kyle Simpson

You Don't Know JS
Exploring Service Workers

Check out a free preview of the full Exploring Service Workers course

The "The Case for Service Workers" Lesson is part of the full, Exploring Service Workers course featured in this preview video. Here's what you'd learn in this lesson:

Kyle makes a case for service workers by highlighting the responsibility of developers to deliver website experiences thoughtfully.


Transcript from the "The Case for Service Workers" Lesson

>> Kyle Simpson: So the idea that we've just ignored or allowed to accrete over time, we've ignored or allowed to accrete over time this complexity of the way caching technology works and not really worried about it. We've essentially allowed browsers to worry about that problem instead of us. And we just say well, if I throw out some expires headers, that's good enough.

And the truth is it isn't good enough. The truth is that it is our responsibility as the builder of a web experience, I think, this is my opinion, that it's our responsibility as the builder of a web experience to ensure that the person gets to continue to experience as much of that as possible regardless of the conditions that they may be in.

If their Wi-Fi goes out, if there's a storm and the cell towers are knocked down, they should not be completely lost in that web experience. Now, it's entirely true that your web experience may be very dynamic. There may be things that they won't be able to get. A while just recently I was tweeting about this because Twitter has a progressive web app.

And this happens to me all the time, that I'm scrolling through my timeline. And by the way, I use the latest tweets timeline because whatever Twitter keeps trying to do with the most relevant is complete nonsense. But I'm scrolling through my latest tweets timelines, so I'm kinda going back, seeing what have I missed in the last hour or two.

And then, I go get on a plane and my wi-fi is turned off and I open up Twitter, and I get a Twitter app, their progressive web app is there and my timeline's completely gone. And I was tweeting about this, and I was saying why is it that we call this a progressive web app, but it's nothing useful whatsoever to me if it's a blank screen that I can't see any content.

And I tweeted about this. Obviously, ironically, I'm tweeting about my frustrations with Twitter. But I tweeted about this because there's more than just the Twitter progressive web app that does this. I tweeted about it, and I said wouldn't it be great [LAUGH] if my timeline was still there?

And what I got was all these myopic responses from people like well, there's no possible way that Twitter could cache the entire stream of billions of tweets in your website.
>> Kyle Simpson: And that's not what I was asking for, is it?
>> Kyle Simpson: And actually, when I say that in that sarcastic way, that's actually the prevailing mindset that drives product managers to design shitty products.

Pardon my French, but it's what causes them to design that, is because they're not thinking from the perspective of what would I want in that position? They're not using their basic human empathy to say if I got on the plane what would I want to see. I don't need to see the entirety of all Twitter.

I don't need them to somehow break the laws of quantum mechanics and download information to my phone when I have no Internet connection. You know what I want? The same timeline that I was already looking at.
>> Kyle Simpson: How about the hundred tweets before and the hundred tweets after the current tweet that I'm looking at?

Is that too much to ask? And yet, we don't build stuff like this, cuz we don't think and we don't care.
>> Kyle Simpson: This is what I'm talking about. This is why I say that every single website on the Internet needs to change the way they think about the information that is presented to people and the experiences.

And they're not always gonna be perfect, but they oughtta not just be blank unusable screens.
>> Kyle Simpson: So when we get into the stuff today, what we're gonna be doing is we have this very simple site, it's kind of like a very primitive sort of a blogging site, right?

And the idea is if I'm on a blog, I wanna be able to navigate the blogs that I've seen. I don't necessarily, I definitely don't need to see brand new blogs that you've posted since the last time I was online. But I need to be able to see all the stuff that I saw while I was online.

And that is just a website. Now, we're gonna do a little bit of handling of dynamicism, and we'll talk about variety of strategies around dynamic stuff. Because every single product and every single experience is gonna have a slightly different nuanced answer to that question. When you click a button to Tweet something and you're not online, Twitter has to decide what do I do with that?

Do I pretend as if it tweeted and then later synchronize that and send it out? Do I tell you, nope, it didn't tweet cuz you're not online? Do I do somewhere in the middle? Do I save it and tell you I didn't tweet it but it's saved, when you come back online, here's gonna be your tweet and then you can click the button to tweet it?

Or any gray area in between. And I can't tell Twitter what the right answer is. I can certainly complain about it, but I can't tell what the right answer is. But what I can tell them is, it is clear that somebody's not thinking about this stuff. And they're not thinking about it at your site or your site or your site.

And I'm not trying to pick on you. But I experienced this really terrible web, and I can tell you where almost nobody's thinking about this stuff. How do we gracefully fall back, not only when the Internet is completely down, but let's even think about what would you do if somebody had an Internet connection and they clicked the tweet button, but it's so slow that it takes minutes and it hasn't actually responded that the tweet came out.

They have Internet connection, they're not offline. It's just they're on such terrible 2g that we don't even know whether the information got to the server. So it's not relevant to me what the server does, that's a totally separate concern. What's relevant to me in this question is how are you gonna handle that for the user?

What are you gonna tell them? Are you gonna tell them sorry, you've lost your tweet? That's what happens to me on Twitter. When I click a tweet button to send off a tweet, and I happen to have been online when I started, but I'm offline at that moment to go send a tweet, it goes away.

Poof! It's just gone. So I can tell you they're not thinking about it. Or if they're thinking about it, they're not implementing it, or they're not testing it, or something. Because that is not what a user wants, to just have, poof, it's gone. I thought it went out and it didn't go out, and then I go back later and nobody ever saw that tweet.

I didn't get all my likes. I mean, this is a critical crisis. Okay? So hopefully that sets up for you what I'm talking about why this is so important for us to think about this differently. And I'm not gonna try to convince you that you should make every single experience that you've ever created into an installable app on somebody's home screen.

We're not gonna talk about that stuff. But what we are gonna talk about is using this technology to try to improve the experiences for users, specifically on websites. Whether your website is completely static, or totally dynamic, or somewhere in between, there is some strategy that you can use this technology to implement.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now