Do This to Improve Image Loading on Your Website

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

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

  • @HazimSami
    @HazimSami 5 ปีที่แล้ว +90

    Jen, you are doing an outstanding job with the team at Mozilla. Thank you all for the great content on this channel. Keep 'em coming 😊

    • @gradybraylen3569
      @gradybraylen3569 3 ปีที่แล้ว

      i guess im randomly asking but does someone know of a way to log back into an instagram account??
      I somehow forgot the account password. I love any tips you can offer me

  • @AmandeepSingh-hd8iq
    @AmandeepSingh-hd8iq ปีที่แล้ว

    Watching Jen's video is more addictive than watching Netflix. Supreb content with amazing explanation. Thank you so much.

  • @VRwithAndrew
    @VRwithAndrew 5 ปีที่แล้ว +21

    I'm not a web developer. But, I find these videos incredibly interesting and well put together.

  • @biboswanroy6699
    @biboswanroy6699 4 ปีที่แล้ว

    Watched and applied it immediately on my website. Boom experience is so much better now

  • @wellsdorian07
    @wellsdorian07 5 ปีที่แล้ว +4

    Thank you for the help to stop "Janky" sites!

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

    This makes sense - and I know the aspect ratio in many situations... but in a lot (leaning towards 'most') situations - I'm not going to know the height of a given image in a CMS. For example a poster image on a single resource page (say, a blog) - I'll set width but allow the client to shove whatever in there. But - the CMS knows the image size - so I guess you just have to draw the line on how each image works. Good info! I think this will be useful in 30% of cases for me. Especially grid type images. The rest usually involves a lot of the contextual image switching.

  • @PhillipStewartYYZ
    @PhillipStewartYYZ 3 ปีที่แล้ว

    Great video, thanks. Whenever I see image size not reserved for images and web pages I think what is wrong with these people the solution has been in place since 1995. Always include height and width on IMG.

  • @swampflux
    @swampflux 5 ปีที่แล้ว +35

    height: doggo

  • @joshdeltener-work
    @joshdeltener-work 3 ปีที่แล้ว +1

    What was the result of the convo? It's been 2 years and I haven't heard anything.

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

    Can't wait for a CSS aspect ratio property. It would make so many time consuming styles faster to write.

  • @MarcWorrell
    @MarcWorrell 4 ปีที่แล้ว

    Thanks! This is now being added and tested in the open source CMS Zotonic.

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

    Looking at the last part there with multiple images, it looks like you could just simply put the aspect ratio in pixels in the html sizing. For example.. width="16" height="9" or whatever. It could actually be helpful for quickly identifying the aspect ratio when looking at it later. Now I have to go experiment. :)

  • @jackwright7014
    @jackwright7014 4 ปีที่แล้ว +5

    Automatic aspect ratios without JS... 🤯 Thanks goodness!

  • @Yoni-G
    @Yoni-G 5 ปีที่แล้ว

    Thanks for this very informative video. The dilemma with all brand new techniques is that the average user may still have a slightly older browser, and I don't mean IE6, but maybe a browser that has not been updated for a year. So, unless your audience is tech-savvy, it may be worth waiting a bit before applying these techniques.

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

    Fabulous video. I'd really appreciate your expertise in answering a couple of questions if you have the time!
    If we want to use different pictures of different sizes according to a screen break. What would be the best way to approach this.
    For instance


    The issue above is that I can provide height and width for the mobile image, but if the user loads on the desktop, I don't understand yet, how to provide fixed width for that.
    Would love to hear your thoughts on this! Thanks

  • @liho26
    @liho26 5 ปีที่แล้ว +3

    @Mozilla Developer Hi Jen! Thank you for nice content on your channel. One small question. When Mozilla will start supports subgrid for CSS Grid?

    • @liho26
      @liho26 5 ปีที่แล้ว

      @@MozillaDeveloper Nice! Many thanks!

  • @xGSTQ
    @xGSTQ 4 ปีที่แล้ว

    This is awesome! Still going to have to support older browsers though for now, so I'm still going to tap into the fluid container with padding hack for lazy loading assets

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

    This is great news, thanks. Will the aspect ratio also be calculated for width and height attributes on `` and `` elements as well as ``? In fact, could widths and heights be applied to any block-level element?

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

    Great video and glad to hear Firefox will be calculating aspect ratio on it's own - as well as working on a css property to allow developers to define a custom one!
    I would also like to know how to have an image load the appropriate sized image for the container (the size of the img/picture element). I know srcset primarily uses the viewport size but what if you have an image that is the size of the viewport (or close enough with a bit of margin/padding) on a mobile device but then want it to only be a maximum of 300px width when on a 1080 monitor? Since it goes by viewport it will load the 1080w image instead of the 300px that the img element is limited to.

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

    Awesome! It works! Super helpful. THANKS

  • @richpeacock
    @richpeacock 4 ปีที่แล้ว

    I love geeking out with Mozilla. Everyone seems like people I would have been pals with before the media went divisive in 2016 and split the world into two.

  • @RaveYoda
    @RaveYoda 3 ปีที่แล้ว

    I didn't know srcset existed...huh...very cool!!

  • @PeriMoritz
    @PeriMoritz 5 ปีที่แล้ว +4

    I have a thought/question, and this is browser support aside. If I use the width/height of 1/1 or 2/4 or 5/7 or 16/9 would that suffice to support the aspect ratio feature coming with Firefox 71? Throw in an Object-fit: cover? Just thinking out loud for possible more flexible options.

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

      I had the same thought about object fit.

    • @jimbo2150
      @jimbo2150 5 ปีที่แล้ว

      I had the same thought and it believe would also go to art direction point. Some people may be fine with using object-fit: cover but some may not want the image to cut off some potentially important parts of an image that may be closer to the edge and may instead want to define their own custom aspect ratios so that the entire image always displays rather than being clipped or expanding outside the img/picture element.

    • @malydok
      @malydok 5 ปีที่แล้ว

      Doesn't adding `object-fit` negate the thing that this feature is trying to introduce? With `object-fit` you're deffering the image size to be determined by the size of its container.

  • @SeanGoresht
    @SeanGoresht 5 ปีที่แล้ว

    If you're already using srcset AND sizes, would specifying the image width and height be necessary?

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

    Really good 👍. Thanks Jen

  • @mohamedhussainsh7913
    @mohamedhussainsh7913 4 ปีที่แล้ว

    Thanks for this, do we have any caniuse page to check the state of this feature in different browsers?... and will this applicable to normal elements if not , we left with padding hack to give the proper aspect ratio without jank

  • @th34lch3m1st
    @th34lch3m1st 3 ปีที่แล้ว

    What happen if I have to set dimensions with vh an vw?

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

    Very cool! Thanks for the info!

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

    Hi Jen, and thanks for another great video. To go slightly off-topic, are we ever getting a fallback image attribute for , in case image provided to the src for whichever reason fails to load? Of course, we handle all this stuff either using some hacks or with JS, but I think it's time that we actually get an attribute e.g. src-fallback to which we can provide a default image if the src one doesn't load. Any thoughts? Thanks.

    • @JSBroadcast
      @JSBroadcast 5 ปีที่แล้ว

      @@MozillaDeveloper The thing I'm mentioning solves a problem that for whatever reason an image doesn't load e.g. was removed from the server, it would get replaced by some default placeholder image. You can see those examples all over the internet (primarily social platforms) and the way we solve it right now is with JS e.g. if an image returns 404 or if there's an error in general, you replace the image with a placeholder image. This is to keep the UI not show that ugly image missing icon, pretty much ruins the UI when it happens.

    • @robertlinder8464
      @robertlinder8464 5 ปีที่แล้ว

      See these related issues: github.com/whatwg/html/issues/3858 + github.com/w3c/csswg-drafts/issues/656

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

    This is very useful! Many thanks!

  • @patrickc.6183
    @patrickc.6183 5 ปีที่แล้ว +2

    Great video Jen! Are there any plans to bring native lazy loading of images to Firefox?

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

      Also my thought, and I am sure it is on the docket for a future release. Correct me if I am wrong but I don't believe this is part of the HTML standard - yet. I think it is just a draft made by a Chrome dev and so far has only been adopted by Chome/Blink. I am sure it will eventually be adopted by the HTML spec and other browsers will begin adding it.

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

      Its in the works on firefox but there are some build errors. Also, webkit has build errors as well. Probably the most popular new feature on chrome currently.

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

    Something like this:
    .responsive-img{
    height: attr(data-ratio);
    }

  • @MichaelLockhart
    @MichaelLockhart 5 ปีที่แล้ว

    Since the units for width= and height= are unspecified, and it's only the ratio between them that seems to be important, could we just express it as a ratio in the img tag?
    width="15" height="10" in this case?
    Well, only if we also use the CSS height: auto
    For Firefox, with this update, that would work. But for other browsers, or Firefox 69-70, I think the "jank" would return. In cases where there's no CSS height auto, the browsers still interpret it as pixels, so it would make the space 10 pixels high to begin with. :(

  • @jagc2206
    @jagc2206 5 ปีที่แล้ว

    Hmmm,
    I am really conflicted on the height/width not being in pixels but when you don't have it set to auto in css it will also be the height in pixels.
    I guess it used to make sense when css wasn't really a thing, but does it still make sense?

  • @benjaminli21
    @benjaminli21 5 ปีที่แล้ว

    But... I might be wrong or misheard what you said... Aren't settings image width and height explicitly in the HTML tag makes the image not responsive?
    OK, I need to rewatch to see if I missed anything... (I kind of thinking that width:100% and height:auto in the CSS is what doing the responsive magic even we set width and height attribute explicitly in the HTML tag...
    And thank you for the sharing! Good job!😆

    • @benjaminli21
      @benjaminli21 5 ปีที่แล้ว

      Hmm... I get that now... In older browser you can't get both (the solution of jankness and responsiveness) to work but the newer browser will try to grab the info of image and make a ratio and save our lives 😁 well, thanks! But if the solution is only work on newer browser, I think we better come up a backward compatible solution...
      Anyway thanks 😁

  • @milindkhadse556
    @milindkhadse556 4 ปีที่แล้ว

    Great video. Thanks to upload :)

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

    why dont just add new attribute named maintain which maintain the aspect

  • @funkologie
    @funkologie 5 ปีที่แล้ว

    Wondering what I can do, whitout to know width and height...

  • @Andrey-il8rh
    @Andrey-il8rh 4 ปีที่แล้ว

    Is there any update with width/height on the element? It's already almost a year passed, I need it badly 😢

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

    this content is great, thanks heaps!

  • @selfishprimate
    @selfishprimate 5 ปีที่แล้ว

    Wouldn't it be much easier to use some kind of HTML attribute like aspect-ratio="16:9"? Or some data attributes can be used to fix that like data-ratio="16:9". I think it will be much human-readable and semantic.

  • @ThomasKempDesign
    @ThomasKempDesign 5 ปีที่แล้ว

    Will this work if you use compressive imagery?

  • @castletown999
    @castletown999 5 ปีที่แล้ว

    Would it not be better to include the image dimensions in a header that can be fetched from the server quickly, without waiting for the entire image?

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

      @@MozillaDeveloper I understand. But the problem with it is that the image information is in two places. It's in the image file and in the HTML. If I want to substitute a different image I have to change the HTML too. This is not normal form (where a given piece of information should be stored in one place only - to avoid them getting out of sync) . I have a site where some images are in multiple places, so this gets to be major chore. I have to run around trying to remember all the pages that use it so I can modify the size attributes.
      What would be REALLY cool is if the server could include the image sizes of all the images on the page in the page header. Sure, it would only get the static images but it would still help a lot.

  • @cotojesakra
    @cotojesakra 4 ปีที่แล้ว

    So is this Firefox only solution?

  • @wpezdeveloperdot_com1301
    @wpezdeveloperdot_com1301 5 ปีที่แล้ว

    Height and width? Ha! What more people need to understand is sizes and scrset. One of the main reasons images lag is because the value of the sizes attribute is suboptimal. This is especially true with WordPress. Removing the jank is nice. But an empty slot isn't a great UX either.

  • @JeffBachtel
    @JeffBachtel 5 ปีที่แล้ว

    Hi Jen I know you're active on Twitter so you might have noticed - I upgraded to FF 71.0 after watching your video and the twitter.com web interface seems to be waaaay more jank (presumably due to image loading). Have you noticed a change? Is this just something Twitter's gonna have to fix with image tags?

  • @sankalp_choudhary
    @sankalp_choudhary 5 ปีที่แล้ว +11

    Love mozilla

  • @aaronharding3695
    @aaronharding3695 4 ปีที่แล้ว

    hey Jen! how would you support images with variable widths in this way? if the image in the html is `` what would happen if the css applied was `width: 100%; height: auto;`?

  • @cristopher5837
    @cristopher5837 5 ปีที่แล้ว

    What if we don't know the actual aspect ratio of the image?

    • @cristopher5837
      @cristopher5837 5 ปีที่แล้ว

      ​@@MozillaDeveloper Thank You for for your answer Jen! I wish I knew this before

  • @MouhamadouDer
    @MouhamadouDer 5 ปีที่แล้ว

    Great video!

  • @alikin
    @alikin 4 ปีที่แล้ว

    2020 now! And this technique now works for any browser like latest version of Chrome and Safari?

    • @MinasKeshishyan
      @MinasKeshishyan 4 ปีที่แล้ว

      It works for Chrome and Firefox, but not for Safari.

    • @MinasKeshishyan
      @MinasKeshishyan 4 ปีที่แล้ว

      @@MozillaDeveloper awesome!

    • @ahsath
      @ahsath 4 ปีที่แล้ว

      @@MozillaDeveloper Where can we see support for this in Safari?

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

      @@ahsath This change shipped in Safari 13.1 this spring. I'm not sure where I can point you for documentation - for instance, this isn't really a new 'feature' that's listed on Can I Use - but I know from talking to engineers that this has definitely shipped in Safari, as well as Chrome, Edge, and Firefox. Testing should show as much.

    • @ahsath
      @ahsath 4 ปีที่แล้ว

      @@JenSimmons yep, it ain't a feature here's some mdn docs for it developer.mozilla.org/en-US/docs/Web/Media/images/aspect_ratio_mapping thanks for let it me know that's is available for safari

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

    Thanks!! :D

  • @oguzakankan518
    @oguzakankan518 5 ปีที่แล้ว

    Where have you been? 😄

  • @FrankEBailey
    @FrankEBailey 4 ปีที่แล้ว +4

    Huh! Everything old is new again :D

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

    I feel like this is going to become troubling... I bet people are just going to put something like width="16" height="9" and it'll be a mess 🤔
    Anyway, thanks a lot!

    • @xerzy
      @xerzy 5 ปีที่แล้ว

      @Still waiting for Fry Retrocompatibility, in essence, where old browsers are not going to render things properly

    • @MinasKeshishyan
      @MinasKeshishyan 4 ปีที่แล้ว

      ​@@xerzy How old should be a browser to not use width / height applied by css?

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

    Aprooved 👍

  • @Foguest
    @Foguest 3 ปีที่แล้ว

    💪

  • @psfdek
    @psfdek 4 ปีที่แล้ว

    Давно пора!