Skip to content

[Enhancement]: Support lazy loading of images in the Slide block #93

@mi5t4n

Description

@mi5t4n

Feature description

Currently, images within the Slide block do not include the loading="lazy" attribute. Ideally, this should be handled by the WordPress core Image block; however, the feature is still a work in progress (WIP): WordPress/gutenberg#41475

There are two possible approaches to address this:

  1. Use the render_block_{$block_name} filter to programmatically add the loading="lazy" attribute to <img> elements within the Slide block.
  2. Implement lazy loading via JavaScript, following the approach outlined in the Embla Carousel example: https://www.embla-carousel.com/docs/examples/predefined#lazy-load

Note

The first approach is straightforward and requires minimal effort to implement. In contrast, the second approach would require changes to the existing markup along with a refactor of the current implementation.

Problem it solves

It improves performance by ensuring images are loaded only when the carousel enters the visible viewport.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions