kthornbloom / Smoothproducts

A simple, lightweight and responsive product image viewer using jQuery
kthornbloom.com/smoothproducts
185 stars 89 forks source link

Load background images after dom #44

Open Deam94 opened 5 years ago

Deam94 commented 5 years ago

Is there any way to load the "small images" - background images after the dom is load ? The problem here is i cant use something like lazyload on it and a large number of images end up in slow page load.

Something like: <a href="images/1.jpg"><img src="images/1_tb.jpg" alt=""></a> -> <a href="images/1.jpg"><img data-src="images/1_tb.jpg" alt=""></a>

~

var thumb = $('img', this).attr('src')
firstThumb = $('img', this)[0].src

->

var thumb = $('img', this).data('src')
firstThumb = $('img', this).data('src')

...

You can use $(document).ready(function(){ instead of $(window).on('load', function() { then