Reduce image size: use srcset to automatically choose the right image

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

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

  • @LaxmikantBhumkar
    @LaxmikantBhumkar 5 лет назад +10

    Nice to gain this valuable info on image sizes. 😊

  • @nathnolt
    @nathnolt 5 лет назад +14

    In the case of that specific image, it's an icon so using an SVG image would be way smaller and look crisp always.

    • @Yetipfote
      @Yetipfote 4 года назад +1

      I only use le GIF

  • @umangternate
    @umangternate 3 года назад +2

    Is there any CSS or JS trick that can do the work automatically? For example, if the device is a smartphone then the image will downsize automatically?

  • @cintron3d
    @cintron3d 5 лет назад +2

    Good to know, I hadn't heard of srcset before. Thanks!
    I know the real point of this video was to highlight srcset, but the opening frames it as a video about optimizing images. For that, I try to load SVG files over raster images whenever possible - much smaller foot-print and they scale.

  • @davidpicarazzi
    @davidpicarazzi 4 года назад +1

    Can someone explain what she means by how an image should be no more than 200 kb times the portion of the screen it takes up? How do you know the portion of the screen it takes up? Front end noob here just starting out

  • @user-cx1de8xy8d
    @user-cx1de8xy8d 6 месяцев назад

    how did it work if you didnt specified sizes attribute?? I have understood that if you use "w" descriptor in srcset you MUST specify a sizes atrr

  • @pdsnpsnldlqnop3330
    @pdsnpsnldlqnop3330 5 лет назад +2

    Is it not better to put the image dimensions in the img element and then to use mod_pagespeed to create the srcset images? In this way you don't need to care about resizing your asset images manually.

  • @power-tools
    @power-tools 4 года назад +3

    Thank you, but what about "sizes" attribute?

  • @PawanKumar-bj7gp
    @PawanKumar-bj7gp 5 лет назад +4

    Great insights into image loading on browser, your accent made it more cool.

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

    super good video

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

    Hello and thank you! How can I structure the code when I want to have webp and jpg images in different sizes depending on the viewport?

  • @nepalcodetv6298
    @nepalcodetv6298 5 лет назад +1

    only problem is it doesn't work on resizing because it is cached..!!! Need To Refreshed hard one.

  • @kipyegonline
    @kipyegonline 5 лет назад

    This is so true..been procrastinating on this srcset..time to duplicate them images..tomorrow

  • @orj
    @orj 5 лет назад +3

    2:20 - "Here you show that you have a medium jpeg image".... All I see is a couple of PNGs?

  • @qwerty-mz8is
    @qwerty-mz8is 4 года назад

    Is there an amount of srtSets where the performance of the page gets affected ?
    if i have an image service and add a srcSet per 10px up to 4000px how will that affect performance ?

  • @simonkalu
    @simonkalu 5 лет назад +1

    Great Info. More tutorials on other components that could slow down the webpages

  • @jamaicanfoodsandrecipes
    @jamaicanfoodsandrecipes 4 года назад

    I don't have the audit tap in on my browser, how can I get it?

  • @Alessandro-nq3tm
    @Alessandro-nq3tm 5 лет назад +2

    We use it already! :)

  • @FrancisBoudreau
    @FrancisBoudreau 5 лет назад +1

    "200 kilobytes times the portion of the screen it takes up"... what do you mean? Can you explain this one please?

    • @mancesnowdon1757
      @mancesnowdon1757 5 лет назад

      I think if the image takes 10% of the screen 200kb*10% = 20kb ? but I m not sure

    • @daninlove2924
      @daninlove2924 5 лет назад

      🇺🇸🇰🇭@@mancesnowdon1757

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

    Great Explanation!

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

    Where to add that "srcset" attribute in WordPress? Do I need to add it to every single image manually every time I upload?

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

      It would have to be built into the Wordpress theme that you’re using.

  • @radovansurlak7445
    @radovansurlak7445 5 лет назад +1

    Thanks a lot :)

  • @MAgeCZ
    @MAgeCZ 5 лет назад +1

    Well paradoxically the mobile image is still bigger than desktop one. I think you could be fine with one medium image in webp in this example. Better example would be with desktop image much bigger than mobile image. Like in hero or carousel.

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

    merci boucoup

  • @albertograu3318
    @albertograu3318 5 лет назад

    Cool tip, using this

  • @vasoelias
    @vasoelias 5 лет назад

    So with this attribute srcset="" we don't need to use with it the sizes="" attribute?

    • @patrickalvares4174
      @patrickalvares4174 4 года назад

      Yes, you only need to choose when a version of your image will be used. In the example he showed to us what images would be used in a 400 width screen and 100 width screen. The screen's size of a Pixel 2 apparently is 411 width and 731 height, so the image loaded was the one assigned to this situation. Another thing to think about is if a 400 width assigned image would be used until 199 width in thsi example.

  • @BobCorraro
    @BobCorraro 4 года назад

    Amazing video

  • @andylib
    @andylib 5 лет назад

    Great video

  • @d1eg0ldn
    @d1eg0ldn 5 лет назад

    nice video!

  • @LoggeL
    @LoggeL 5 лет назад +2

    Those images would also be more practical as SVGs since they are mostly simple geometric figures.

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

    I have to remind myself that images in srcset and image in src are not supplementary.

  • @jarosk1977
    @jarosk1977 5 лет назад +6

    You forgot to mention images loaded by CSS

    • @GifCoDigital
      @GifCoDigital 5 лет назад +1

      CSS cant "load" images. If you are referring to using background-image instead of using an tag no images will even begin to download until all CSS is downloaded, parsed, and the CSSOM built. Even if you dont care about proper semantics (which you should) using background-image will give the worst possible performance.

    • @itsbhatt_yt
      @itsbhatt_yt 5 лет назад

      you can use media query in css

    • @canarslan12
      @canarslan12 5 лет назад

      they did not forget, they decided to make video simple

    • @kardashevr
      @kardashevr 5 лет назад +2

      use media queries. css has nothing to do with srcset

    • @error.418
      @error.418 5 лет назад +1

      Yeah, image-set is neat, but this video is about srcset

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

    There's no "voilà"... Nothing in this video indicates that an image from the srcset property was chosen over the one from the src property. And, in my case, it's always choosing the largest image from the srcset.

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

      Look at the network tab and reload the page at different sizes, then you’ll see images loading at different sizes. If it’s always loading the largest image then the code probably has a bug.

  • @equality9304
    @equality9304 4 года назад

    Wow and wow

  • @trappedcat3615
    @trappedcat3615 5 лет назад +2

    Oh for the day when the browser api will auto compress images

  • @bharat_pandey345
    @bharat_pandey345 5 лет назад

    First comment ...💗