0

I am using tiny slider and the vertical slider option causes large layout shifts while loading. I get this message in Google Page Speed "Avoid large layout shifts". I would like to fix. Please can someone recommend a fix?

I have 2 vertical sliders next to each other and 1 stretches below the viewport while loading.

Demo link/slider setting: https://codepen.io/matt-giggs/pen/wvyMBzR

jQuery(window).bind("load", function() {
    
  if (document.querySelectorAll('.tiny-slider').length > 0) {
      const slider1 = tns({
            container: ".tiny-slider",
            items: 3,
            slideBy: 1,
            axis: 'vertical',
            autoplayDirection: 'forward',
              "mouseDrag": false,
            "swipeAngle": false,
            "speed": 500,
            "autoplay": false,
            touch:false,
            autoplayButtonOutput : false,
            nav: false,
            loop: true,
            autoHeight:false,
            autoWidth:false,
            preventActionWhenRunning : true,
            preventScrollOnTouch : 'auto',
                     controlsContainer: '.slider-controls',
                              onInit: function (info) {


                              }   
      });
  }

    
});

Here's how it looks when loading - loading

Loaded - Loaded

1 Answers1

0

You need to set static height for .tiny-slider class

Soroka
  • 1
  • 1
  • 2
  • Your answer could be improved by adding a little textual explanation why and how it works and a small code example. – ahuemmer Jul 16 '22 at 06:11