Wordpress LScache Plugin: How to load excluded CSS asynchronously?
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hi, I have optimized my website using your plugin. I have to exclude a few CSS files to display everything correctly. But now the excluded CSS files are not loading in an asynchronous way. I just want to not minify and combine the selected CSS files but still load them in an asynchronous manner. Is this possible? Loading CSS async is no good idea. In most cases it causes content/layout shifting and this is not good if you want to get a good Pagespeed score. Loading CSS async can have advantages, but needs a strategy for loading critical and uncritical css. unfortunately not from plugin side but you can just simple edit the source code and add attribute media=print onload=this.media=all to that CSS file , or use litespeed_buffer_after filter to edit the content on-the-fly. I found this in your documentation. function remove_broken_style( $content ) return str_replace( .content opacity:0 , , $content ) add_filter( litespeed_buffer_after, remove_broken_style, 0) This code will solve my issue and will load CSS in an asynchronous manner, right? thats what I have mentioned in my last reply about the litespeed_buffer_after filter you need to adapt a bit of it , to make it search your existing CSS file code and add async attribute into it Yeah, I got it. Can you please give me an example of CSS files? And if possible a guide or an article link where I can learn more about these filters. you have the doc already , just need to learn a bit about PHPs str_replace() function lets say your page has a HTML code , like then you can replace it like return str_replace( something.css , something.css media=print onload=this.media=all , $content ) this will then turn into output code like didn test the code , but idea is like this Thanks! I dont know how to use this filter but will learn and use it. Your example is not working for me but its a good reference for me. you just need a quick class on PHPs function str_replace basically , just find the CSS link , and replace it with async attribute in the code like my above example
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference