Stop loading of images with javascript (lazyload)?

前端 未结 9 2396
醉梦人生
醉梦人生 2020-12-19 08:03

I am trying to stop the loading of images with javascript on dom ready and then init the loading whenever i want, a so called lazy loading of images. Something like this:

9条回答
  •  一向
    一向 (楼主)
    2020-12-19 08:36

    With JavaScript you do it like this.

    var imagesArray = document.querySelectorAll('img');
    
    for(var i=0; i

    Consider using Vanilla Javascript first.

提交回复
热议问题