Replies: 5 comments 7 replies
-
Converted this into a discussion because it's not a bug in the plugin. I think the CLS happens by the WP built-in lazy-load function which loads only visible images. Add a filter to your /**
* Disable lazy-load
*/
add_filter( 'wp_lazy_loading_enabled', '__return_false' ); Some optimising/caching plugins do lazy-load images as well, check them too if CLS still exists. Solved? |
Beta Was this translation helpful? Give feedback.
-
No, this doesn't help. I also tried to disable cache but it's the same. |
Beta Was this translation helpful? Give feedback.
-
And from yesterday cache is disabled, because of other problem with mini-cart. It caches mini-cart. |
Beta Was this translation helpful? Give feedback.
-
Thank you for you info but this doesn't solve CLS. I use it also on my new site which has latest version of theme and swier plugin and it's same. |
Beta Was this translation helpful? Give feedback.
-
I will join that discussion here. @Fision I solved the issue with some "hacks". But am quite happy with the result. I am not sure if links are allowed here? If not @crftwrk just remove it ;) Btw, I had the issue with all slider libraries i implemented so far (Swiper.js / Splide.js / Owl Carousel) and as soon as you don't want the js being render blocking and you want the slider above the fold you run into these issues. You have to provide your own swiper.js init script and some css hacks to get the cards sizes correctly directly after load before init. As a starting point my js to init the swiper: const bsSwiper = document.querySelectorAll('.cards');
for (i = 0; i < bsSwiper.length; i++) {
bsSwiper[i].classList.add('cards-' + i);
var slider = new Swiper('.cards-' + i, {
// Options
slidesPerView: "auto",
loop: false,
grabCursor: true,
slidesOffsetBefore: 20,
scrollbar: {
el: ".swiper-scrollbar",
hide:0,
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I use swiper I get bad CLS (cumulutive layout shifting) in Google.
Trouble is that slider just preload first image and little bit later slides get sliding in.
Do you know a way to avoid/ improve this.
Best regards,
Simon
Beta Was this translation helpful? Give feedback.
All reactions