important The advice in this gist will increase the size of the documents you send to the browser (ever so slightly), so technically it's bad for performance. However, if for any reason you want to achieve zero W3C validation errors when using lozad.js
in Roots/sage you can follow the instructions below.
Open app/controllers/app.php
and add the following to the class:
public static function fakeImg()
{
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
}
Replace unset($attr['src']);
with $attr['src'] = App::fakeImg();
.
<img src="{{App::fakeImg()}}" data-src="/the-real-src.png" class="lozad" alt="..." width="..." height="..." />