Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
Swiper.js with lazy image loading initiating at the wrong height on mobile

I have updated my website to have lazy loading images with swiper.js.

When the page loads and swiper is initiated, swiper sets the height of the div containing the slides wrong. Its briefly sets the height to 460px which is the hieght on desktop. When the images are loaded the height is then updated to 186px which is correct for mobile.

I only noticed this after lazy loading was setup.

How can I stop swiper initiating at the wrong size?

This is what it looks like briefly for a second. Example

The slide image is prefilled with a placeholder image, width 1200px, height 460px. Then CSS setting the image to width 100% and height auto;

This is my script.

    const myswiperban = new Swiper('.swiper-container-ban-wide', {
            loop: true,
            pagination: {
                el: '.swiper-pagination-ban-wide',
                clickable: true
            },
            navigation: {
                nextEl: '.swiper-button-next-ban-wide',
                prevEl: '.swiper-button-prev-ban-wide',
            },
            slidesPerView:1,
            freeMode:true,
            autoplay: {
                delay: 3000
            },
            autoHeight:true,
            preloadImages: false,
            lazy: {
                loadPrevNext: true
            },
    });

Any ideas?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!