This is not a duplicate of this because it also uses the document.ready
approach which obviously does not work.
I want to avoid that the browser loads images (<img>
) nested within hidden <div>
elements.
So I tried this, however the javascript gets executed too late, the browser already starts to download images that it shouldn't.
$(document).ready(function() {
$('div').not(":visible").each(function () {
$(this).find('img').each(function() {
$(this).attr("src","");
});
});
});
Is there a good javascript solution for this?
Or do I have to use <img srctmp="...."/>
and then replace srctmp
by src
via javascript for those images which are NOT nested within a hidden <div>
?