Horje
How to force/trigger the load of Wordpress native lazy loading images without scrolling (with a js to run 3 seconds after page load)? - Wordpress Solution
I don't like lazy-loading because it looks quite ugly for the user in terms of UX. However, I understand the benefits (faster page load, low bandwidth, high PageSpeed scores etc.) I am planning to write a javascript code which will: Stay in the bottom > Wait for the page to fully load > After 3 seconds it will work > Force load all the images which were lazy-loaded previously during initial page load With this, I won't lose any speed scores (because it will load as normal with lazy loaded images) But, also will load the full images when everything is done, so user won't notice. (we do the same for loading live chat scripts. It works pretty nice) It will probably look something like this:

<script>
window.onload = function() {
    setTimeout(function(){ 
        var ForceLoadImages = document.createElement('script');
        ForceLoadImages.type = 'text/javascript';
        ForceLoadImages.src = 'link-to-the-script-to-force-load-images.js';
        document.body.appendChild(chatScript);
    }, 3000);
};
</script>
I am not a js expert. This was just a dummy example to give an idea. I am specifically asking how to write the content of that "link-to-the-script-to-force-load-images.js" part. Will appreciate any inputs. There was a similar question here, but need an answer for Wordpress: https://stackoverflow.com/questions/30839469/how-to-force-loading-images-for-the-webpages-installed-lazy-load-without-scrol Thanks in advance!

Solution - 1

so you mean you want to load images after 3 sec. once the page loads completely?


Solution - 2

From the example you showed it seems like they are loading a placeholder first then after load the actual image url is appended to the image tag https://jsfiddle.net/e2wkp9zh/ I did a quick fiddle on it, check it out, let me know if it works Monit


Solution - 3

Can you please share your webpage URL?


Solution - 4

oups... bad answer :)





Wordpress

Related
Need help with a PHP IF statement - Wordpress Solution Need help with a PHP IF statement - Wordpress Solution
There are no options in my dashboard on the left where the pages and p - Wordpress Solution There are no options in my dashboard on the left where the pages and p - Wordpress Solution
Need to auto select authors on import - Wordpress Solution Need to auto select authors on import - Wordpress Solution
Merging post data from post ID on edit screen - Wordpress Solution Merging post data from post ID on edit screen - Wordpress Solution
Shortcode not working on AJAX call - Wordpress Solution Shortcode not working on AJAX call - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
21