Conditionally Preloading background images served via LiteSpeed Cache
-
My goal is to preload images in the initial viewport when the page loads.
For some reason background images are not always served as .webp, even when all other images are being served as .webp. This is making preloading very difficult for the hero background image.
I have created a snippet which checks if the browser supports .webp, and if it does, it preloads .webp, otherwise it preloads .jpg. However, LiteSpeed cache is very unreliable in serving .webp for background images, even when the browser supports it. I have also tried adding a check to see if the LiteSpeed Cache plugin is serving the WebP version of the image before preload, but this didn’t seem to work either.The issue here is that as much as I have tried to dynamically preload the background image, in most instances I am preloading a webp when litespeed is serving a jpg, this causes 2 formats of the image to load and the preloaded image is not even used.
Can you please advise?
- The topic ‘Conditionally Preloading background images served via LiteSpeed Cache’ is closed to new replies.