davidhirtz/yii2-lazysizes

High performance and SEO friendly lazy loader for images (responsive and normal), iframes and more, that detects any visibility changes triggered through user interaction, CSS or JavaScript without configuration.

Installs: 1 222

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 3

Forks: 1

Open Issues: 0

Type:yii2-extension

v2.3.0 2022-09-24 06:59 UTC

This package is auto-updated.

Last update: 2024-11-24 11:33:23 UTC


README

lazysizes is a fast (jank-free), SEO-friendly and self-initializing lazyloader for images (including responsive images picture/srcset), iframes, scripts/widgets and much more.

Installation

The preferred way to install this extension is through composer.

php composer.phar require --prefer-dist davidhirtz/yii2-lazysizes "*"

Usage

Once the extension is installed, simply use it in your views. The following example shows you how to add an lazysizes powered image tag.

\davidhirtz\yii2\lazysizes\AssetBundle::register($this);
echo \davidhirtz\yii2\lazysizes\Html::lazyImg($srcset, $options);

Upgrade from V1

Important: AssetBundle is no longer registered by calling Html::lazyImg().