Skip to main content

DeprecateLazysizes

Discourages use of the lazysizes JavaScript library for lazy loading images, iframes, and scripts.

You should avoid using third-party libraries over native browser features to avoid large JavaScript bundle sizes and slow load times. Learn more about theme performance.

This check identifies uses of the lazyload class, data-srcset and data-sizes attributes, and data-sizes="auto".


The following examples contain code snippets that either fail or pass this check.

The following example includes a lazyload class:

<img src="a.jpg" className="lazyload" />

The following example includes a lazyload class, a data-srcset attribute, a data-sizes attribute, and data-sizes="auto":

<img
alt="House by the lake"
data-sizes="auto"
data-srcset="small.jpg 500w,
medium.jpg 640w,
big.jpg 1024w"
data-src="medium.jpg"
className="lazyload"
/>

The following example uses the native loading attribute instead of the lazysizes library:

<img src="a.jpg" loading="lazy" />

Anchor to Disabling this checkDisabling this check

You should disable this check only if you want to support lazy loading of images in browsers that don't support the loading="lazy" attribute.


Was this page helpful?