Wordpress LScache Plugin: Lazyload on background-image
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hello, Im currently using WP Rocket but I have a Litespeed web server so I would like to change, as Litespeed looks far way better. Before doing this, I would like to know if I can lazyload background-image, using for example a data-bg attribute. Ive search without success. Is it possible ? If not, maybe in the future ? Thank for the support. Hi, Well , actually I am not sure sure , but you can try If not, maybe in the future ? in case it cant , you can use 3rd party lazyload plugin with LSCWP , as long as you dont enable lazyload on both part , it should be fine WP 5.5 will come with native lazyload on its own , so we will see what do we do when it releases Best regards, How can I try ? Do you use a specific JS library ? And, Ive checked the roadmap of WP 5.5, it looks like lazyload should apply only on . Hi, Huh ? you can install LSCWP, enable lazyload to try Best regards, It wont work without some trick. I tried, and it did not work. And youve already said it was in your to-do : https://wordpress.org/support/topic/lazy-load-background-images-4/ That is why I asked you if LS uses a specific JS library. For example, WP Rocket uses https://github.com/verlok/vanilla-lazyload, which can lazyload background image using data-bg attributes. Ok, I found a solution. For the others, you may add a function like this, to manually add a data-bg attribute to your div or anything else. And add a data-lazyloaded attribute to this same div. It works, but I was expecting to add a class instead of data-lazyloaded. (function($) use strict $(#section-69-5381).attr(data-bg, url(https://yourwebsite.fr/wp-content/uploads/2020/07/couv_noct.webp)) $(#section-69-5381).attr(data-lazyloaded,) (jQuery))
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference