Using Magento Commerce 2.3.5-p2.

I'm changing the template of the layered navigation from a custom module like this:

<referenceBlock name="catalog.navigation.renderer"

This works correctly.

I am displaying images for some filters, and I want to have them lazy-loaded with Magefan_Lazyload.

The module has a plugin in frontend/di.xml:

<type name="Magento\Framework\View\Element\AbstractBlock">
        <plugin name="magefan_lazyload_lock"
                type="Magefan\LazyLoad\Plugin\BlockPlugin" sortOrder="1000"/>

In my opinion, this should work for all blocks that extend Magento\Framework\View\Element\AbstractBlock, so for example for all Magento\Framework\View\Element\Template blocks.

It works for some Template-blocks, but it doesn't work for some other blocks, such as catalog.leftnav, or the one I am changing above.

I also added debug code to Magento\Framework\View\Element\AbstractBlock::toHtml(), and it seems that this method is never called for my block. Also, I don't think the toHtml() method is overwritten somewhere.

Any tips?

I am running in developer mode. Strange enough, it works different in production mode - catalog.leftnav is recognized, but still not catalog.navigation.renderer.

I also tried changing the plugin's sortOrder to 1, this didn't work either.

1 Answer 1


I recommend to check the Magento 2 Lazy Load extension documentation here.

The extension has an option to define images in what blocks need to be lazy-loaded - "Lazy Load Blocks" option where you need to define one of these:

  1. block name in the layout
  2. block class name, e.g.: MyCompany\MyModule\Block\Someblock\Interceptor
  3. block .phtml template name, e.g.: MyCompany_MyModule::folder/template.phtml

You can check how it works here on github - "isEnabled" method.

If you want to enable lazy loading for some specific cms block or page, or other WYSIWYG content, you need to add this comment somewhere in the content:

  • I already did all of that. Configuration is fine, and I am not a first time user of that module ;) also, as I pointed more, production mode „hits“ some more blocks than developer mode, but still not all of them. The blocks I mentioned are not even running through isEnabled(), this is what I find weird. Commented Jun 15, 2021 at 9:59
  • @simonthesorcerer, do you use varnish?
    – lemk0
    Commented Jun 15, 2021 at 10:40
  • Not on my local machine; I use default Magento2 FPC, but have it disabled for development, and cleaning/flushing the cache has no effect on the blocks that run through isEnabled() Commented Jun 15, 2021 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.