Refactoring of replacement behavior
- replacement occurs not directly after the construction of the image, but within the
onload
oronerror
callback of the image itself. - The custom
onloadCallback
andonerrorCallback
will be invoked immediately before the replacement, so you can add some classes or do some other stuff. - The
onreplaceCallback
will be invoked after the actual replacement. - The advantage is, that the placeholder can hold the styling of the lazy image (e.g. the spinner) and is not deleted until the image is completely loaded.
Migration:
- Check your
onerrorCallback
: It's no longer for the missingdata-src
anddata-alt
attribute. With this callback you can define the action if the image could not be loaded properly. - The
data-onerror-handler
doesn't exist anymore. Please use theonerrorCallback
instead. - Check the styling and position of your spinner. The styling can be placed on the placeholder itself and will be removed after the image is loaded in the background.