I have researched this problem a lot, but to no avail. Essentially, I want to do this:
1) Replace the src attribute on all images with a placeholder, for example 'blank.gif'
2) Add the original HTML5 data attribute with the original image location
3) Lazyload images (for the correct use of the data-original attribute)
What I tried without success:
1) attaching this eventlistener document.addEventListener('beforeload', doBeforeLoad, true);
with this function
function beforeload() { var blank = 'image/location/images/blank.gif'; $('img').each(function() { var orig = $(this).attr('src'); $(this).attr('data-original',orig); $(this).attr('src',blank); console.log("changing all data on images"); }); }
2) on the document. Already sure that this will not work.
I have no idea if this is possible, so any help | offer | the resource will be very grateful
PS: for example, I want to make it work here ) (because it's a heavy article)
source share