{"id":286080,"date":"2019-04-08T15:28:11","date_gmt":"2019-04-08T22:28:11","guid":{"rendered":"http:\/\/css-tricks.com\/?p=286080"},"modified":"2019-07-10T16:03:37","modified_gmt":"2019-07-10T23:03:37","slug":"native-lazy-loading","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/native-lazy-loading\/","title":{"rendered":"Native Lazy Loading"},"content":{"rendered":"

IntersectionObserver<\/code> has made lazy loading a lot easier<\/a> and more efficient than it used to be, but to do it really right you still gotta remove the src<\/code> and such, which is cumbersome. It’s definitely not as easy as:<\/p>\n

<img src=\"celebration.jpg\" loading=\"lazy\" alt=\"...\" \/><\/code><\/pre>\n

<\/p>\n

Addy Osmani<\/a> says it’s coming in Chrome 75:<\/p>\n

\n

The loading<\/code> attribute allows a browser to defer loading offscreen images and iframes until users scroll near them. loading<\/code> supports three values:<\/p>\n

    \n
  • lazy<\/code><\/strong>: is a good candidate for lazy loading. <\/li>\n
  • eager<\/code><\/strong>: is not a good candidate for lazy loading. Load right away.<\/li>\n
  • auto<\/code><\/strong>: browser will determine whether or not to lazily load.<\/li>\n<\/ul>\n<\/blockquote>\n

    I’ll probably end up writing a WordPress content filter for this site that adds that attribute for every dang image on this site. Hallelujah, I say, and godspeed other browsers.<\/p>\n

    Easy lazy loading of images<\/em> will have the biggest impact on the site as a whole, but lazy loaded iframes<\/em> will be even bigger for the individual sites that use them. I’m into it.<\/a><\/p>\n

    \n

    Yes yes whatever native lazy loading of images but lazy loading of iframes is gonna be a goddamn game changer for ad tech: https:\/\/t.co\/ADGc1UsVBf<\/a><\/p>\n

    — Laurie Voss (@seldo) April 8, 2019<\/a><\/p><\/blockquote>\n