Wordpress LScache Plugin: Data-no-optimize=1? doesnt work with styles
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hello, I think I may have discovered a small bug with Litespeed. The data-no-optimize= 1 HTML attribute only works with scripts, not styles. The theme Im using generates its own critical style thats injected in the header, but when CSS Combine External and Inline setting is enabled that inline style is added to the Litespeed CSS file, even its using the data-no-optimize= 1 tag to exclude it from optimization. The inline tags with data-no-optimize= 1 are successfully ignored from combine. Thanks, Ionut The page I need help with: https://shopniac.ro/ Hi, Could you please specify how did you add the css ? I tested with code like this and it works on my test site that is excluded from being optmed Best regards, Hello QTWRK, Im adding the critical css as so: echo include_once(get_template_directory() . /assets/css/critical/main-critical.min.css) echo This is hooked with an action Ive made in the theme in header.php, just below the charset line. In Source it shows up correctly as ?, but once the combine action is checked these styles disappear (theyre moved into the Litespeed CSS file). I have two styles and one script with data-no-optimize hooked into the same action. Styles are combined, while the script works as intended, and is left untouched. Hi, okay , I see , you are making it inline CSS data-no-optimize=1 works on CSS file for sure , but it seems didnt work for inline CSS not sure if it was designed that way or a bug , will check up with devs for the time being , you can add partial content of that inline CSS into CSS exclude field Best regards, Partials seem to work just fine. Thanks for the tip. Fixed in https://github.com/litespeedtech/lscache_wp/commit/4432202d501198138230ff36d71f4aa0c749db4b Thanks.
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference