Lazy loading your images just got a whole lot easier. If you’re not familiar, lazy-loading is the practice of delaying the load of certain content on a page until a user scrolls near it.
If a user never scrolls, the content never loads.
Page speed performance, mobile… good for all that.
But, as of Chrome 75, that’s no longer necessary. A new attribute for <img> and <iframe> tags, loading” will be supported. Supported parameters are:
- lazy: good candidate for lazy loading.
- eager: not a good candidate for lazy loading. Load right away.
- auto: browser will determine whether or not to lazily load.
Implementation is as such:
<img source="dope" loading="lazy"> <img source="dope" loading="eager"> <img source="dope" loading="auto"> <iframe src="dope.html" loading="lazy"></iframe>
If the loading attribute is not added, it defaults to “auto”. The best part is, even without full browser support, you can start implementing this now. It won’t affect anything if the browser doesn’t support it.
But, for the ones that do (once more and more browsers jump on board), the benefit will automatically kick in.
Anyway, one of the many little things in HTML that can make your life a lost easier… if you know them. There’s been more and more of this kind of stuff coming out lately.
One of the ways you can keep up with all of it is my Beginner’s Guide to HTML course on SkillShare. Discover all the little things you might have missed while learning how to write standards-compliant HTML.
And, we build real things.
Like a HTML5 audio and video player complete with a playlist and autoplay. In any case, if you want to keep going with your HTML training, you can access it for FREE over on SkillShare.
All the details on that are here: http://johnmorrisonline.com/skillshare