How to asynchronously load views blocks or views attachments in Drupal 8

You, DrupalDrupal views
Back

The lazy load or asynchronously load is a nice way to avoid too much pressure on the server or avoid being cashed by the reverse proxy or something else.

So how do we do it in Drupal 8.

I'm so glad that I found the Views Lazy Load module, even though it doesn't have a official Drupal 8 release it has a Patch that we can use to make it work in Drupal 8. Take a look at the issue Port Views Lazy Load to Drupal 8.

You can either use manual patching or composer to do that.

How to use:

The module uses Views Display Extender plugin API to implement that. It uses built-in Drupal Ajax functionality to facilitate the lazy load.

Before use go to Views settings and enable the Display Extender.

Navigate to : admin/structure/views/settings/advanced and enable the plugin.

Views Laze Load

Then you can go to your view and you'll see the option to enable the lazy load in your view.

Views Laze Load inside a View

© Heshan Wanigasooriya.RSS

🍪 This site does not track you.