Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

If you are on Drupal 8 or 9, please stay on the 8.x-3.x branch, but if you are on Drupal 10 or 11, you can move on to 4.0.x branch.

The functionality is still identical in 4.0.x and 8.x-3.x branches. But on the next release 4.0.x branch will only target Drupal 10 and 11.

This is a simple Drupal module which lets you enable lazy-loading images and iframes.

This module depends on the lazysizes library.

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.

Features

  • Now uses lazysizes library for rich features
  • Supports inline-images and inline-iframes (Enabled per text-format)
  • Supports image fields with following field formatters:
    • Colorbox colorbox
    • Image image
    • Responsive image responsive_image
    • Media Thumbnail media_thumbnail
  • Provides a hook_lazy_field_formatters_alter(&$formatters) hook for your theme or module for adding field formatters programmatically.
  • Supports native lazy-loading via loading="auto" attribute for Chrome browsers. This option can be disabled in the settings, so that the lazysizes library can be used for all browsers instead.
  • Added 2 new (optional) image formatters: Image (Lazy-load) and Responsive image (Lazy-load). These can be very useful with the Views.
  • Lazy-loading is automatically disabled for AMP pages.
  • Additional paths can be defined to disable lazy-loading.
  • Supports upgrading from 8.x-2.0 release.

Installation

Download and install like any other module, and library; into modules/contrib/lazy, and libraries/lazysizes folders respectively.

For installing via Composer make sure to read How to use Composer to install Lazy-load module and its dependency

How to use

Once installed, you can enable Lazy-loading in 3 different ways:

via text formats

This method enables lazy-loading for inline-images and inline-iframes in Body (formatted, text) fields.

  1. Open Text formats and editors
  2. Configure your choice of text formats. i.e. Full HTML.
  3. Enable the lazy filter labeled as Lazy-load images and iframes

via field formatters

In entity display settings page, edit the image formatters. Supporting image fields display a checkbox in the field formatting settings. Check the box to enable lazy-loading for that image field, for that view mode.

via Form API

See LazyForm.php for a quick example.

Breaking changes since 2.x

If you're looking for 8.x-2.x documentation go to 8.x-2.x/README.md

bLazy library replaced with lazysizes.
If you customized the bLazy configuration in 8.x-2.x, you should checkout the
documentation for code-migration options for lazysizes.

Documentation

Change records for Lazy-load

https://www.drupal.org/list-changes/lazy

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
9
Tracked since
Aug 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
4.0.2 Stable Jul 7, 2024
8.x-3.16 Stable Jul 7, 2024
8.x-3.15 Stable Jul 7, 2024
8.x-3.14 Stable Jul 6, 2024
4.0.1 Stable Jul 6, 2024
4.0.0 Stable Jul 6, 2024
4.0.x-dev Dev Jul 6, 2024
8.x-3.13 Stable Jul 6, 2024
8.x-3.12 Stable Aug 31, 2023