Service Workers - Registration, LifeCycle, Events, and Dev Tools

Поделиться
HTML-код
  • Опубликовано: 4 янв 2025

Комментарии • 65

  • @redhood7105
    @redhood7105 Год назад +9

    Honestly, This and your other playlists should be gold standard for any youtube educator who creates content for the serious learners. Thank you

  • @scottbockelman310
    @scottbockelman310 2 года назад +11

    Best set of concise and informative tutorials I have found on PWAs and JavaScript.
    And I love the almost Bob Ross relaxed delivery. Thanks!

  • @bluemangroupie
    @bluemangroupie Год назад +1

    Thanks!

  • @shujaatali8414
    @shujaatali8414 4 месяца назад

    No one can stop me to listen full series. Awesome I loved the way you delivered.

  • @sriramananthasivan482
    @sriramananthasivan482 Год назад +1

    Prof3ssorSt3v3 - what an awesome series. I suppose you are the David Attenborough of the JavaScript world.. beautiful narration and explanation! . Grateful and thankful for your effort.

  • @akashshah1080
    @akashshah1080 Год назад +1

    Thanks Steve!

  • @kumailn7662
    @kumailn7662 Год назад +2

    Awesome man, awesome, the way you explained is awesome

  • @rebelmachine88
    @rebelmachine88 3 года назад +4

    Thank you for this series, looking forward to the rest. Great explanations as always!

  • @lalmimohammedissam8654
    @lalmimohammedissam8654 Год назад +2

    I would love to be one of your students in real life. You make this look like a piece of cake, as they say, 'easy peasy lemon squeezy.' Thank you a lot professor

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +3

      You can be if you come here www.algonquincollege.com/mediaanddesign/program/mobile-application-design-and-development/#overview
      😀

  • @mikebryan3270
    @mikebryan3270 3 года назад

    I recently started experimenting with changing the wall colour of an image of a room stored as background with an SVG mapping the areas to change the colour. Your video has prompted me to consider storing the user’s colour selection and room image. An inspirational video! Thanks

  • @staticselector7318
    @staticselector7318 3 года назад +1

    2:16 😄😆😂🤣 If I can type ".then" super relatable 👌 Awesome series 👍

  • @kelechi.E
    @kelechi.E 2 года назад +1

    I think a little introduction into service workers and when they are used would really be helpful.

  • @shanusharma.
    @shanusharma. Год назад

    Such a nice video, thank you so much for making it.

  • @kienphan6436
    @kienphan6436 7 месяцев назад

    Thank you sir! This is very helpful.

  • @UmapathiKrishnan
    @UmapathiKrishnan 9 месяцев назад

    Thank you for your clear explanation

  • @TheAjayluke
    @TheAjayluke 3 года назад

    Great explanation for service workers. Loved it! Thank you for your effort.

  • @marinamohsen6940
    @marinamohsen6940 2 года назад

    This was so informative , Thank You!

  • @derkvanderveen8938
    @derkvanderveen8938 3 года назад +1

    Great tutorial, thanks.

  • @abhim6380
    @abhim6380 3 года назад +1

    Thank you for this.

  • @tudoresan3119
    @tudoresan3119 3 года назад

    Very interesting! Thank you!

  • @marcepires
    @marcepires 2 года назад

    Excelente! gracias Mister!

  • @endergelisenosasunaatag275
    @endergelisenosasunaatag275 Год назад +1

    Hi Steve, first of all, thank you for sharing those videos, I want to ask you I read MDN docs like this but there are many interfaces, methods, properties on a subject, do these videos give me everything about service workers? should I keep reading MDN docs as a jr? I feel like slow.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +3

      Well, I've been doing web development for over 25 years... I still read the docs, and MDN, and articles, and watch tutorials....
      This is a life long learning career.
      You will never know it all. Enjoy the journey.

  • @leolowe22
    @leolowe22 8 месяцев назад

    Hey! Thanks for the video, Just wanted to understand, The part where we delete the sw, so at one place it shows that its deleted and just below it still shows that its running and active at 17:21

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад +1

      The dev tools are not always completely accurate for service workers when it comes to updating the status. It's like there are different parts of the code that track different things and not all of them listen for the same events.
      The note at the top appeared saying that it was deleted. But the line with the green dot down below hadn't received the message yet.
      I've seen situations where the same worker is shown twice too.
      It may have to do with garbage collection of the worker. The connection between the page and worker has been severed but the actual script is still in memory. So, since it is still in memory the line with the green dot still thinks it is the current active worker, just because it was the most recent one, and it still exists, and it was activated at some point.

  • @KEVIN-nf9oh
    @KEVIN-nf9oh 2 года назад

    Hello professor! Can the same service worker principles be used within a Browser-Extension to monitor a fetch call and do [some logic]? I'm partcularly interested because of the introduction of Manifest Version 3 in chromium this year. Thanks as always!

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +1

      I don't know what the level of support is for service workers in browser extensions for Chrome or Firefox

    • @KEVIN-nf9oh
      @KEVIN-nf9oh 2 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 Ahh alright, no issues :)

  • @frontend_ko
    @frontend_ko Год назад +1

    can i use this as a state manager like zustand or redux in react?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +2

      You can build a state management script into a service worker using messaging but it's not really what they are intended for.

  • @shushens
    @shushens Год назад

    Amazing video! I learnt a lot! I have a question though. If you have multiple tabs open, which are essentially independent instances of the web application you have built, I assume they are running on different processes. If they are using the same service worker, how does the connection between them look like? The service worker will be a thread in the main process and the JS logic for each app will run in a thread of its own process and they will talk to each other through Mojo or something?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      The service worker will be on its own thread and all the tabs will share a thread for the scripts on the tabs.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      Here is a Playlist about ways to communicate between tabs or windows and service workers
      ruclips.net/p/PLyuRouwmQCjk-hvtzQSrCSxBd4S0nOMh9

  • @DIY88-mi9im
    @DIY88-mi9im Месяц назад

    Hey there, Steve! Thank you for this video.
    I have an issue.
    Set up my local host through vscode Live Server
    Unregistered sw and reloaded page, following your steps.
    Then Chrome's Service Workers tab only showed "See all registrations" link, and Edge's Application tab crashed whatsoever...
    While inspecting HTML file in devtools, I found inline script injected by Live Server.
    It took precedence over my script and showed its own message in console. I couldn't edit it in devtools, where shows as long as Live Server runs.
    It would be great if you have some ideas about it.
    Thank you again for helpfull tutorials!

  • @siddhant3852
    @siddhant3852 5 месяцев назад

    Is this still relevant for today tech landscape, I want to use service worker for offline storage and caching some assets.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 месяцев назад

      @siddhant3852 absolutely. Service workers are the core technology behind progressive web apps PWA.

  • @codingroom928
    @codingroom928 Год назад

    is there any way to communicate between different browsers like from chrome to edge or firefox?

  • @ricardodesirat2590
    @ricardodesirat2590 2 года назад

    Hi Steve
    Just out of curiosity, is there a special reason for having all the logic inside an object (const APP)?
    Thank you

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      Namespacing is a great way to avoid naming conflicts with other code and libraries, it helps to organize your code, and I teach it as a first step towards using ES modules.

    • @ricardodesirat2590
      @ricardodesirat2590 2 года назад

      @@SteveGriffith-Prof3ssorSt3v3 Thanks! Good to know. So, implementig it on everything is always a good idea? As well as the init on DOMContentLoaded?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +1

      @@ricardodesirat2590 it is a good practice and will make you think about how you organize your code more. And it will help you transition to modules

    • @ricardodesirat2590
      @ricardodesirat2590 2 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 Thanks, Steve! This is a true learning channel.

  • @anushaavanigadda8124
    @anushaavanigadda8124 Год назад

    How can I use service workers with typescript in a nextjs app?

  • @norbertperka9231
    @norbertperka9231 3 года назад

    hi Steve ,good tutorial but still doesn't work for me .I can't registered SW it testing on localhost ,don't know if webpack is responsible for this . Thanks Anyway for good explanation

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад

      check for spelling of the filename, errors in the browser dev console, if another service worker is already registered for localhost in the browser application tab.

    • @norbertperka9231
      @norbertperka9231 3 года назад

      @@SteveGriffith-Prof3ssorSt3v3 I unregistered everything ,that's what console return to me Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('localhost:5500/') with script ('localhost:5500/sw.js'): A bad HTTP response code (404) was received when fetching the script. I change localhost; was 8080 and enabled it for save though flag in chrome , not sure if webpack is messing or im doing probably somethig wrong , i tried many option what i found on MdM about SW
      BY the way thank You for replying for my comment

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад

      If you are getting a 404 error and you are running a webpack build script then the change in path from webpack is definitely your issue.

    • @norbertperka9231
      @norbertperka9231 3 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 thanks Steve a LOT, I knew it must be something with it I just can't sort it out ,will have to gig dipper in to it

    • @norbertperka9231
      @norbertperka9231 3 года назад

      probably will try workerbox

  • @Turnables
    @Turnables 5 месяцев назад

    Why am I now learning about this?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 месяцев назад

      @@Turnables I would guess that you are learning about PWA

    • @NphiniT
      @NphiniT 5 месяцев назад

      @@SteveGriffith-Prof3ssorSt3v3 It's actually a little more interesting. There is an experiment builder called Gorilla that allows one to write JavaScript to create custom components for the experiment. Now I'm trying to add a component to detect AI usage in respondents' text responses which requires me to make an asynchronous request. But all the lifecycle events are synchronous. So I was here because I was wondering if I could use a service worker to spawn a separate thread and have the life cycle method being called to wait for the service worker response before continuing. Basically, a way to call an asynchronous function within a synchronous function and have it wait for the async to complete before continuing 😫
      If you have any ideas, I will gladly take them. But this service worker approach seems to not be it

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 месяцев назад +1

      @@NphiniT sounds like you need a web worker or a shared web worker.

  • @USPSLaura
    @USPSLaura 8 месяцев назад

  • @whatappstatus6937
    @whatappstatus6937 2 месяца назад

    Please Talk Slow