You are loading Images wrong! Use this instead 😍

Sdílet
Vložit
  • čas přidán 28. 07. 2024
  • As developers, we have to deal a lot with images, from blogs to landing pages, it's all about giving the users the best impression when visiting your website.
    In this tutorial, we'll explore the best approaches you can follow to improve image loading on your website as well as implement lazy loading using React with awesome placeholders (before the image is fully loaded) with a great user experience.
    ⭐ Timestamps ⭐
    00:00 Intro
    01:04 How Unsplash does load images?
    02:53 Approach 01: Use the browser lazy-loading feature
    05:49 Approach 02: Use Lazy-loading React component
    07:45 Why the React component is not always perfect?
    09:04 Approach 03: Use Blurhash placeholder w/ lazy-loading
    11:53 Server-side of using Blurhash with Node
    13:42 How Blurhash can improve the UX by 10x
    ⚡️ Image Lazy Loading repo
    github.com/ipenywis/img-lazy-...
    🧭 Turn Design into React Code | From prototype to Full website in no time
    • Turn Design into React...
    🧭 Watch Tutorial on Designing the website on Figma
    • I Design a onecolor We...
    🧭 Watch Create a Modern React Login/Register Form with smooth Animations
    • Create a Modern React ...
    🧭 Debug React Apps Like a Pro | Master Debugging from Zero to Hero with Chrome DevTools
    • Debug React Apps Like ...
    🧭 Master React Like Pro w/ Redux, Typescript, and GraphQL | Beginner to Advanced in React
    • Master React Like Pro ...
    🧭 Learn Redux For Beginners | React Redux from Zero To Hero to build a real-world app
    • Debug React Apps Like ...
    🧭 Build Login/Register API Server w/ Authentication | JWT Express AUTH using Passport.JS and Sequelize
    • Build Login/Register A...
    🧭 Introduction to GraphQL with Apollo and React
    • Introduction to GraphQ...
    🐦 Follow me on Twitter: / ipenywis
    💻 Github Profile: github.com/ipenywis
    Made with 💗 by Coderone

Komentáře • 72

  • @xyz-ey7ul
    @xyz-ey7ul Před rokem +1

    I was about to watch a number videos just to understand the purpose of react lazy feature but this video answered everything and more

  • @georgekalogeropoulos1813
    @georgekalogeropoulos1813 Před rokem +112

    Nice video but I believe 15 minutes are way too much for just suggesting 2 libraries . Would be nice to show a video of how can you code that blur effect without the libraries.

    • @anosikegideon4142
      @anosikegideon4142 Před rokem +1

      bro!! He just spent a lot of time explaining UI/UX

    • @dekafmusic
      @dekafmusic Před 4 měsíci

      @@anosikegideon4142 sure helped me in some way ngl

    • @AhmadMughal1
      @AhmadMughal1 Před 19 dny

      Finally someone that thought the same as i did. The amount of unnecessary information this guy has loaded in this to reach the 10 min mark is astounding.

  • @codeworthy
    @codeworthy Před rokem

    this is awesome man!...i like the last one

  • @projottasantos4778
    @projottasantos4778 Před rokem

    Thank you, it works perfect!

  • @videolucu5900
    @videolucu5900 Před rokem

    thanks a lot!!! so nice reverb

  • @jesusjuvinao8210
    @jesusjuvinao8210 Před rokem

    Hay diferencia en usar el componente Image de next e implementar este paquete?

  • @rifatskdev
    @rifatskdev Před rokem

    Tysm, did everything as described

  • @HaNaxHeart
    @HaNaxHeart Před rokem

    hi, does anyone know what beforeLoad do in 14:20? cuz I think just use the onLoad prop to control the logic is enough?

  • @mmozedev
    @mmozedev Před rokem +88

    The main thing here that is not emphasized enough is the fact that width and height (or atleast height) need to be set. Without that information, lazy load won't work. This means your server needs to return the dimensions with the photo URL.

    • @thedigitalceo
      @thedigitalceo Před rokem +20

      Exactly right. And it’s the same issue with the NextJS image component which is amazing but you still need to specify width and height which is something that goes against most good responsive design related to imagery. So it’s a catch 22

    • @Rhidayah
      @Rhidayah Před rokem +1

      Well, the reason why that width and height need to be set. It’s because, if your image not fully rendered. It became shifted, and after complete it will be jump into bottom. You will be notice, if the image combine with paragraphs. That’s why you should be set that dimensions, to give a space.

    • @shoutmeback2587
      @shoutmeback2587 Před rokem +1

      @@Rhidayah What would be the approach for optimizing the images in react applications? Is there some other techniques too?

    • @Rust_Rust_Rust
      @Rust_Rust_Rust Před rokem

      can the heights and widths be a percentage of the users viewport? Or does it have to be a fixed value (px, rem, em, etc.)

  • @noredine
    @noredine Před rokem

    Is there any way to load them Sequentially?
    For example loading the 2nd, 5th, 3st, then 1st and so on doesn't look very good

  • @ernestdesbordes
    @ernestdesbordes Před rokem

    Blurhash is the best and cool way. I use that in all my projects.

  • @alessandromarin3803
    @alessandromarin3803 Před rokem

    Thank you so much! TNice tutorials video helped produce fire soft thanks bro❤️

  • @nro337
    @nro337 Před rokem

    Thank you!

  • @mubarakalalawi305
    @mubarakalalawi305 Před rokem

    In The setup tNice tutorials was a really helpful video but I'm using soft soft 12, is there a reason why I can't hear my own soft play? I click to play

  • @andreiolar6104
    @andreiolar6104 Před rokem +15

    Well, the second option would have probably worked similar. The issue on why the initial blurred download is very slow is because you have specified the same image for both the src and the placeholder src. That should have been a very light image for fast download :)

    • @Rhidayah
      @Rhidayah Před rokem

      Ye, my method just generate 2 versions, one 60x60 pixel and other is the orginal one. You don’t blur it. Because if the 1st version expand to w300 h300 make it blurry because small image.

    • @brawlgammer4424
      @brawlgammer4424 Před rokem

      He just wanted to push this BlurHash library full-force.

    • @bleakCode
      @bleakCode Před 9 měsíci

      good point. It ruins the point of lazy loading to have to load the same image as placeholder. Instead you can maybe use a default background image

  • @anasouardini
    @anasouardini Před rokem

    is there an implementation for astro? I looked it up but I found nothing.

  • @3hustle
    @3hustle Před 2 měsíci

    bro is there any way to preload video at the startign only and then able to seek to any point without buffering, i dont know if youtube allow this or not but is it possible somehow through programming?

  • @jorgeassaf
    @jorgeassaf Před rokem

    Hello bro, how could you do it with nextjs Image component and blurDataUrl?

  • @ziat1988
    @ziat1988 Před rokem

    thanks for the great share

  • @raiikagaming
    @raiikagaming Před rokem +5

    Those who wants to use blurhash as a dynamic image, might also consider the server performance to use blurhash,
    since I've worked with creating thumbnails via PHP, and it actually cost a massive server performance and it could make a server down if used in a looping state.

    • @dreamecho100
      @dreamecho100 Před rokem

      Is there a solution for this, except for caching the result?

  • @dimafurs6248
    @dimafurs6248 Před rokem +16

    In my opinion, CoderOne is one of the best channels related to Web Development tips and projects on CZcams rn. Thank you very much, Islem, for all your efforts and work done in helping us to understand these topics better!

  • @eyout7973
    @eyout7973 Před rokem

    Thanks a lot

  • @petronini
    @petronini Před rokem

    Great video, man! Could we have a look at the code to play with it and get on better? Thanks!

  • @hamadoungom8281
    @hamadoungom8281 Před rokem

    now i am in a good mood

  • @SXsoft99
    @SXsoft99 Před rokem +2

    what if you use the "loading="lazy"" attribute on the image tag? native out of the box in html

    • @kumarankur
      @kumarankur Před rokem

      you can use it, but as mentioned in the video it is not widely supported in the lesser known/used browsers, better to use intersection observer.

  • @vincentcottalorda2105
    @vincentcottalorda2105 Před rokem +2

    Or using NextJS Image component 😊

  • @MrSatyavinay
    @MrSatyavinay Před rokem

    Cool!

  • @code-island
    @code-island Před rokem

    pretty cool

  • @MonirulIslam-sg7oh
    @MonirulIslam-sg7oh Před 5 měsíci

    Thank you for the video. How do I store the hash value when I add the image from backend say with laravel and nodejs?

    • @CoderOne
      @CoderOne  Před 5 měsíci

      The hash has to be stored inside the database. For example, if you upload the image, you have to generate the hash out of the image and store it alongside the image data in the database. So later on, the hash would be returned with the image data.

    • @MonirulIslam-sg7oh
      @MonirulIslam-sg7oh Před 5 měsíci

      @@CoderOne yes that what I have asked, its just hash like password hash or something different?

  • @arihantjain8347
    @arihantjain8347 Před rokem

    just wanted to know, after going through the code are we using react-lazy-loading-component and blurhash together?

  • @1337-coder
    @1337-coder Před rokem

    what if you have authentication? this doesnt work. you need to fetch the images as blobs first.

  • @rambhajansaw5933
    @rambhajansaw5933 Před rokem

    who has been blind their whole life and can finally see. I can't express my gratitude in words but tNice tutorials is the best I can do. THANK YOU SO

  • @shinobi_coder88
    @shinobi_coder88 Před rokem

    How to use blurhash with dynamic images? From TMDB API for example. I use lazy loading image in NextJs and it still quite slow

    • @shinobi_coder88
      @shinobi_coder88 Před rokem

      @Ta Chi Bao interesting, can you share me the repo? thanks

  • @mohamedyoussef8835
    @mohamedyoussef8835 Před rokem

    Awesome video +++++++++++++++ 🙂

  • @spoconykubus3480
    @spoconykubus3480 Před 3 měsíci

    but this blurbash works good only for box images

  • @brakpseudonimu236
    @brakpseudonimu236 Před rokem

    I'll be honest, small fast loading thumbnails were the best experience, and the only big one loading is the one I clicked, but that's just a boomer preference.

  • @paologonzales4361
    @paologonzales4361 Před rokem

    where is the github repo?

  • @dunguyen2924
    @dunguyen2924 Před rokem

    How’s it going?

  • @anaqo7175
    @anaqo7175 Před rokem

    Sa. TNice tutorials quarantine is making question my whole existence.

  • @cristianbilu
    @cristianbilu Před rokem

    I am triggered by the fact you use create reacy app.. Why??

  • @izzetah2358
    @izzetah2358 Před rokem

    Thanks for helping the community i will be so glad if you cancel continue your good work

  • @piflom8400
    @piflom8400 Před rokem

    Imagine how much money he would have made if he had ads. There’s 6.6 million views.... he’d be rich

  • @usamakayani6537
    @usamakayani6537 Před 5 měsíci

    Wordpress please

  • @karthikp4484
    @karthikp4484 Před rokem

    this guy voice is similar to webdev simplified

  • @archmad
    @archmad Před rokem

    why lazy load a 4mb image file? load 150k at most for each image. that;s enough

  • @edhahaz
    @edhahaz Před rokem +1

    Lazy loading is the worst way to load images

  • @yadmr3557
    @yadmr3557 Před rokem

    ​♂️

  • @dexion_gaming
    @dexion_gaming Před rokem

    laughs in unlimited free trial

  • @govindagarwal2389
    @govindagarwal2389 Před 10 měsíci +1

    It is easy to do this without libraries, 15 minutes video for suggesting 2 libraries is pathetic. I thought in 15 minutes he will have some information on how to actually do it without library.

  • @razorjhon2622
    @razorjhon2622 Před rokem +1

    too much talking for 2 libraries also you didn't even show us how you did implemented the code :(

  • @muhammadukkasha5048
    @muhammadukkasha5048 Před rokem

    Good video but man pls be specific, your talk was much of telling your experience in many words instead of just showing what's the problem and how to solve it, that's it

  • @omranarchitects7816
    @omranarchitects7816 Před rokem +2

    its blatantly obvious that you're trying to scam people

  • @1879heikkisorsa
    @1879heikkisorsa Před rokem +2

    This video could have been 2 minutes long. Get to the point!

  • @gmc5946
    @gmc5946 Před rokem +1

    you do sure talk a lot

  • @muhammadhasnat9835
    @muhammadhasnat9835 Před 9 měsíci +1

    Video is full of fluff and unnecessary time wasting talk

  • @Haz1Art
    @Haz1Art Před rokem +1

    You talks so much of irrelevant info. This doesnt have to be 15 minutes. Sorry, but such a waste of time.