The Lazy component prefix and when to use it - Nuxt Performance in Depth

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

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

  • @TheAlexLichter
    @TheAlexLichter  10 месяцев назад +3

    Did you use the `Lazy` prefix so far?

    • @RIT_Edition
      @RIT_Edition 10 месяцев назад +1

      Yes

    • @moe8055
      @moe8055 10 месяцев назад +1

      yeah and only on my Footer and since then i sometimes get a strange error telling me failed to load module. But only if you hard reload the page several times. It gets displayed and is hydrated properly tho

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      @@moe8055 Weird. That should work always. Maybe because of redeploys?

    • @jurarexx
      @jurarexx 10 месяцев назад

      @@moe8055 did you try to encapsulate your component with ?

  • @fedvvvv
    @fedvvvv 10 месяцев назад +4

    Fantastic. I haven't looked into performance enhancements yet but I'll start using Lazy Loading for some tabbed components and my modals. This is great!

  • @Andrey-il8rh
    @Andrey-il8rh 10 месяцев назад +2

    It would be so cool if you would make a collab course on Nuxt 3 with Maximilian Schwarzmüller from Academind, it would be like the best course in the world on Nuxt! You both share so practical and easy way of telling about all of those concepts which is so rare these days 👍

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад +1

      Interesting idea! Nothing is impossible 👀
      But being mentioned in a row with Max is already on honor 🙏

  • @wellingtoncapoia
    @wellingtoncapoia 10 месяцев назад +1

    anxiously waiting

  • @thejurex87
    @thejurex87 10 месяцев назад +1

    Another great video. 👍

  • @jydro
    @jydro 10 месяцев назад +1

    Thanks for showing the source code! We're lazy loading some below the fold content, but it's different for mobile and desktop.

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      Yeah, that's the tricky part. If in doubt, rather lazy-load less than penalizing a larger percentage of users.

  • @riyad-appscode
    @riyad-appscode 10 месяцев назад +1

    Awesome video. Thanks a lot 👍

  • @ragura
    @ragura 10 месяцев назад +1

    Thanks for the explanation. Is there room in the series for a deep dive into a combination of cached server routes, local caching (useFetch keys like in your other video) and optimistic UI changes that update the local state and local cache accordingly while invalidating the server's cache after a change is made? I've been hitting this issue in my project where a large list is loaded and small changes can be made to it with post requests, but refreshing all the data just for this small change to be reflected in the UI seems like overkill.

    • @kissu_io
      @kissu_io 10 месяцев назад +2

      Optimistic UI is quite nice (discovered it with Apollo) but it can also be quite tricky for a small amount of benefits. 😅

    • @ragura
      @ragura 10 месяцев назад +1

      I agree, but it's an important UX factor when the refresh load is high. Back in the Vue 2 days I used to handle this with Vuex, which wasn't fun to work with but it got the job done. I think mutations through 'useNuxtData' is what can be used to streamline this.@@kissu_io

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      Great idea. I might cover that in a stream in a future because it might be a bit long for a single video. But let's see, maybe I can shrink it down 😊
      In the meantime, you might want to check nuxt.com/docs/api/composables/use-nuxt-data#optimistic-updates

  • @zuko655
    @zuko655 10 месяцев назад +1

    Thank you for covering features which are perhaps a bit more obscure or not well documented

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

    love the video, thankyouu!!

  • @matanon8454
    @matanon8454 10 месяцев назад +1

    🙏

  • @jahiddev
    @jahiddev 10 месяцев назад +1

    🙌

  • @виртуоз_ру
    @виртуоз_ру 10 месяцев назад +1

    Лучший 👍

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      Большое спасибо ✨

  • @abhinavadarsh7150
    @abhinavadarsh7150 9 месяцев назад +1

    Nice video. Subscribed ❤

  • @cupritchanel5139
    @cupritchanel5139 10 месяцев назад +1

    Terimakasih sharingnya kak salam sukses

  • @randomtimessomehow
    @randomtimessomehow 6 месяцев назад

    I have a question: Do Lazy components automatically effect their child components?
    For example, is this the correct way to do it: or like this:

    • @TheAlexLichter
      @TheAlexLichter  6 месяцев назад +1

      It depends. If the component is passed as slot, then you'd need the prefix. If it is already part of the parent, you can omit it.

    • @randomtimessomehow
      @randomtimessomehow 6 месяцев назад

      Thank you! I appreciate it :)@@TheAlexLichter

  • @jurarexx
    @jurarexx 10 месяцев назад +1

    very useful informations

  • @ivangorobec2803
    @ivangorobec2803 10 месяцев назад

    Thank you, man! That`s very helpfull. Can you please tell about chunk splitting with modern nuxt in future videos?

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      You are welcome!
      What exactly you'd want to know about chunk splitting? How they are split by default and how to customize?

  • @blokche_dev
    @blokche_dev 10 месяцев назад +1

    Interesting! It would be much more useful with directives for placeholder (and loading and error states) as Angular introduced in the latest version.
    Vue lets you define AsyncComponent with loading state at its core but Angular defered views are really powerfull I think. No extra step with lazy declarations.

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад +1

      Technically this is possible in Vue too via defineAsyncComponent as you said (loading/error state), but I agree, a more declarative way would be interesting to see.
      With regards to hydration though, that is also something coming - See github.com/nuxt/nuxt/issues/24242

    • @blokche_dev
      @blokche_dev 10 месяцев назад +1

      @@TheAlexLichter Oh interesting! Thanks.

  • @milos018
    @milos018 10 месяцев назад +1

    I use Lazy almost by default for any Dialog/modal elements as they are not sure to be used in the app, therefore not needed to be loaded... There are other use-cases of course, but this would be the default

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      Yes, that's almost a no-brainer (as long as a possible delay is justifiable when the user clicks on the modal/dialog)

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

    Is there a fallback while the js for the Lazy component is being downloaded? What happens if the chunk load results in error?

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

      You can define a fallback via a named fallback slot, yes 👌
      If any chunk load fails, nuxt will usually reload

  • @tolgabeyazoglu536
    @tolgabeyazoglu536 10 месяцев назад +1

    My understanding is that too much lazy loading is harmful and we should not lazy load components like the navbar footer.

    • @TheAlexLichter
      @TheAlexLichter  10 месяцев назад

      Yes and no.
      ✔ Correct is: Too much lazy-loading is harmful. Also lazy-loading content *above the fold* is not good.
      When it comes to the Footer, I'd say you *can* lazy-load it if it is below the fold, so the user won't see or need it straight away. That's most common for most pages (without a sticky footer).

    • @tolgabeyazoglu536
      @tolgabeyazoglu536 10 месяцев назад +1

      thank you for the answer@@TheAlexLichter

  • @freekeys
    @freekeys 3 месяца назад

    Still don't know where to use in real life application, it would be better if you show some websites that has it, for better visual understanding

    • @TheAlexLichter
      @TheAlexLichter  3 месяца назад

      I might do that, thank you for the suggestion 🙏🏻

    • @freekeys
      @freekeys 3 месяца назад

      @@TheAlexLichter Thank you :)