a3rev / a3-lazy-load

Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
GNU General Public License v3.0
18 stars 11 forks source link

added dynamic svg placeholder #39

Open shakee93 opened 4 years ago

shakee93 commented 4 years ago

adds support to dynamic svg/base64 datauri placeholder instead of the image placeholder. only if there is width and height attribute present in the img tag. this helps eliminate the reflow the jitter we get while lazy loading (cls : https://web.dev/cls/).

this pull doesn't break the default behaviour. it uses the default _placeholder_url only works when

add_filter('a3_lazy_load_svg_placeholder', function () {
    return true;
});

above filter is set to true.

prathamesh-gharat commented 3 years ago

@shakee93 - Thanks, this is a much needed feature in A3 Lazy load.

Note: Base64 encoding is not needed with SVG placeholders.

MythThrazz commented 2 years ago

Amazing idea, just realized that we have a huge CLS issue because of the default placeholder.gif doesn't respect the aspect ratio of the images. Tried it and it worked like a charm!