fritzmg/contao-lazy-load-element

Contao extension to allow lazy loading of content elements or modules.

Fund package maintenance!
fritzmg

Installs: 329

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 1

Open Issues: 1

Type:contao-bundle

1.0.0 2017-02-14 11:29 UTC

This package is auto-updated.

Last update: 2024-04-01 21:15:52 UTC


README

Contao Lazy Load Element

Contao extension to allow lazy loading of content elements or modules.

When installed, this extension provides an additional content element where you can define another content element or module to be lazy loaded on page load. You also have the possibility to let the element reload periodically, once it has been loaded for the first time. And you are able to define, whether the element should only load once it is in the viewport.

To enable this functionality you must enable jQuery in the page layout.

When an element gets loaded or reloaded, either the event lazyload or lazyload-reload will be triggered on that element. This way you can execute your own JavaScript, once an element got loaded (for example to initialize other scripts on the loaded content).

$('#myLazyLoadElement').on('lazyload', function(event)
{
	// …
});

There is also a stylesheet included by default that shows an AJAX loader circle while the element is being loaded or reloaded. To remove it completely you can use this style:

.ce_lazyload:before,
.ce_lazyload:after,
.mod_lazyload:before,
.mod_lazyload:after {
	display: none;
}

Or simply change the styles to your liking. Have a look at the default styles in assets/lazyload.scss.