I currently use two techniques to load images into my webpages. Firstly, I use LazyLoad
to deal with images that are below the fold. This technique seems to work well. The second technique I use is for images above the fold but which are initially hidden from view, they are usually revealed to the user using the onclick
or hover
events. The defer technique I use is to load all these images after the page has loaded (when the onload
event fires).
Google Page Speed Insights doesn’t seem to like my defer technique and reports these hidden images as an opportunity under ‘Defer offscreen images’. I’ve realised that there is a difference between the onload
event and the Time to Interactive
(TTI) ‘event’ that Google uses in Page Speed Insights.
Can anyone advise on a JavaScript technique to replace my ‘defer’ technique which would satisfy Googles criteria.
Here are the messages I get from Page Speed Insights. All the images mentioned here are hidden images above the fold which are loaded after the onload
event fires.1
And here is the Waterfall chart to show that the images are loaded after the load event.2
Thanks for you help.