Speed up your Website with Next.js Dynamic Import Lazy Loading

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ธ.ค. 2024

ความคิดเห็น • 31

  • @eminvesting
    @eminvesting ปีที่แล้ว +8

    Been procrastinating dynamic imports for a while, thanks for the explainer ^^ Keep up the good work, looking forward to your channel growing

    • @tenacity_dev
      @tenacity_dev  ปีที่แล้ว

      Thank you! It means a lot!

  • @Pk_0807
    @Pk_0807 5 หลายเดือนก่อน +2

    That was an clear explanation.. haven't heard this kind of explantion from the other videos. Thanks man

  • @Ziggy0120
    @Ziggy0120 ปีที่แล้ว +2

    This was a really good explanation. Thanks!

  • @danser_theplayer01
    @danser_theplayer01 หลายเดือนก่อน

    I understand that the video is about next.js but literally the import() function is representing the whole concept of a dynamic import, and it works with any javascript.
    Just want people to know that they can do it in vanilla with basically no hand rolling required, you simply make a short function just like making a component. Put up a lodaing screen, await loading, done.
    In one of my projects I'm funneling a lot of modules through a file and importing them as one mean variable. I have 2 folders with similar code and I want only one depending on the environment. So I have an IFEE to load one folder or the other. It's a use case not for fast upfront loading but for conditional loading to remove redundancy.

  • @Its-InderjeetSinghGill
    @Its-InderjeetSinghGill 11 หลายเดือนก่อน

    Well explained. Keep doing the great work ❤

  • @Furki4_4
    @Furki4_4 ปีที่แล้ว +2

    Well explained, thank you so much !

  • @archael18
    @archael18 4 วันที่ผ่านมา

    Couldn't you technically have improved it even further by dynamically importing 'next/dynamic' only in one of the button click events?From my understanding, you would get back to your initial 4kb on initial load since even 'next/dynamic' is not included, then the button click would pull the 15kb from 'next/dynamic' to perform the dynamic import which would immediately be followed up by the 25kb of the heavy component.

  • @ОлегБаранчиков-ф5у
    @ОлегБаранчиков-ф5у 4 หลายเดือนก่อน +1

    Good explanation

  • @JeromeChung
    @JeromeChung ปีที่แล้ว +1

    thanks,it's really good explanation.

  • @york2301
    @york2301 ปีที่แล้ว +2

    How to use next/dynamic without this button, for example do delay load of certain component on first page load?

    • @tenacity_dev
      @tenacity_dev  ปีที่แล้ว +2

      You can add the component directly without any conditionals.
      If you want to load the component only when it's visible then you can Intersection Observer.

    • @york2301
      @york2301 ปีที่แล้ว

      @@tenacity_dev is this kinda same like frame-motion? I have opacity:0 when component is not in view, when it is opacity is set to 1?

  • @techaddictdude
    @techaddictdude 4 หลายเดือนก่อน +1

    How on earth are you using useState in the server component?

    • @tenacity_dev
      @tenacity_dev  4 หลายเดือนก่อน

      Good question, this was before the new Next.js updates where if you want to use state or something similar you had to write "use client" at the top of the component.

  • @klapaucius515
    @klapaucius515 ปีที่แล้ว +1

    This may help, thank you.
    Can you make a video on how to find out what is causing your FCP to be slow?

    • @tenacity_dev
      @tenacity_dev  ปีที่แล้ว +1

      I hope you find it useful!
      I'll keep that in mind for future videos.

    • @prabhurao2773
      @prabhurao2773 7 หลายเดือนก่อน +1

      Your async await calls move to server components and start using suspense your FCP will be improved drastically

  • @york2301
    @york2301 ปีที่แล้ว +1

    Great job!

  • @TheWoselWosel
    @TheWoselWosel 8 หลายเดือนก่อน +1

    Thanks, man! This saved my ass :)

  • @masterv2.045
    @masterv2.045 ปีที่แล้ว

    you rock dude

  • @z1982_
    @z1982_ ปีที่แล้ว +1

    Thanks! But why is it 19kb and not 4.6kb ? :p

    • @tenacity_dev
      @tenacity_dev  ปีที่แล้ว

      Because the `import dynamic from 'next/dynamic'` has it's own JS size.

  • @mr.random8447
    @mr.random8447 ปีที่แล้ว

    Trade off is extra network call

  • @code_zeal6278
    @code_zeal6278 ปีที่แล้ว +1

    thank you!

    • @tenacity_dev
      @tenacity_dev  ปีที่แล้ว

      No problem, glad you found it useful!

  • @kairo2891
    @kairo2891 ปีที่แล้ว

    *Promo SM* ✅

  • @janduna4100
    @janduna4100 หลายเดือนก่อน

    Get to the point, you repeat one thing 50 times...

    • @tenacity_dev
      @tenacity_dev  หลายเดือนก่อน

      It makes sense to repeat important things so they stick with you, I'll keep this in mind for future videos!