Lazy loading images how

后端 未结 6 681
时光说笑
时光说笑 2020-12-05 20:47

I am developing an eshop .At products page based on category i putted some javascript based filtering. However a problem arises if a category has a lot of products. This lin

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 21:01

    I wrote the following code for my own site. I used JQuery: 1. Name all classes, where U want lazy loading by the same name, say "async" 2. Copy the real image location from 'src' to 'alt' attribute 3. After finishing page loading my script will copy all 'alt' values into 'src' Look at example. This is full working sample html:

     
     
     
       http://virtual-doctor.net/images/horoscopes.jpg 
    
    
    

    You can feel the speed in real site, where I used it http://virtual-doctor.net/

提交回复
热议问题