First question: Is there a way to lazy load different images with their corresponding URLs on one page, each image showing after a different delay after the page load?
Scenario:
- first load page (for good SEO and user experience)
- start lazy load of the images in the background
- show image-1 one second after page and lazy load
- show image-2 one second after image-1
- show image-3 one second after image-2
- ....continuing for about 50 little images
I tried hours with code like:
<body>
<div id="a1"></div>
<div id="a2"></div>
<div id="a3"></div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript">
$(window).load(function(){ // This runs when the window has loaded
var img1 = $("<img />").attr('src', 'https://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png').load(function() {
$("#a1").append(img1); // When the image has loaded, stick it in a div
});
var img2 = $("<img />").attr('src', 'https://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png').delay(1000).load(function() {
$("#a2").append(img2);
});
var img3 = $("<img />").attr('src', 'https://www.google.nl/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png').delay(2000).load(function() {
$("#a3").append(img3);
});
});
</script>
Second question: Is it possible to randomize the order of the image above while each image always has his own (different) URL link?