@@ -392,11 +392,13 @@ class Swiper {
392392 swiper . setBreakpoint ( ) ;
393393 }
394394
395- [ ...swiper . el . querySelectorAll ( '[loading="lazy"]' ) ] . forEach ( ( imageEl ) => {
396- if ( imageEl . complete ) {
397- processLazyPreloader ( swiper , imageEl ) ;
398- }
399- } ) ;
395+ if ( swiper . params . lazyPreload ) {
396+ [ ...swiper . el . querySelectorAll ( '[loading="lazy"]' ) ] . forEach ( ( imageEl ) => {
397+ if ( imageEl . complete ) {
398+ processLazyPreloader ( swiper , imageEl ) ;
399+ }
400+ } ) ;
401+ }
400402
401403 swiper . updateSize ( ) ;
402404 swiper . updateSlides ( ) ;
@@ -604,19 +606,23 @@ class Swiper {
604606
605607 // Attach events
606608 swiper . attachEvents ( ) ;
607- const lazyElements = [ ...swiper . el . querySelectorAll ( '[loading="lazy"]' ) ] ;
608- if ( swiper . isElement ) {
609- lazyElements . push ( ...swiper . hostEl . querySelectorAll ( '[loading="lazy"]' ) ) ;
610- }
611- lazyElements . forEach ( ( imageEl ) => {
612- if ( imageEl . complete ) {
613- processLazyPreloader ( swiper , imageEl ) ;
614- } else {
615- imageEl . addEventListener ( 'load' , ( e ) => {
616- processLazyPreloader ( swiper , e . target ) ;
617- } ) ;
609+
610+ if ( swiper . params . lazyPreload ) {
611+ const lazyElements = [ ...swiper . el . querySelectorAll ( '[loading="lazy"]' ) ] ;
612+ if ( swiper . isElement ) {
613+ lazyElements . push ( ...swiper . hostEl . querySelectorAll ( '[loading="lazy"]' ) ) ;
618614 }
619- } ) ;
615+ lazyElements . forEach ( ( imageEl ) => {
616+ if ( imageEl . complete ) {
617+ processLazyPreloader ( swiper , imageEl ) ;
618+ } else {
619+ imageEl . addEventListener ( 'load' , ( e ) => {
620+ processLazyPreloader ( swiper , e . target ) ;
621+ } ) ;
622+ }
623+ } ) ;
624+ }
625+
620626 preload ( swiper ) ;
621627
622628 // Init Flag
0 commit comments