Support » Plugin: LiteSpeed Cache » Data-no-optimize=”1″ doesn’t work with styles

  • Resolved popaionut

    (@popaionut)


    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 I’m using generates its own critical style that’s 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 it’s using the data-no-optimize=”1″ tag to exclude it from optimization.

    The inline <script> tags with data-no-optimize=”1″ are successfully ignored from combine.

    Thanks,
    Ionut

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Could you please specify how did you add the css ?

    I tested with code like this

    <link rel="stylesheet" type="text/css" data-no-optimize="1" href="/test.css">

    and it works on my test site that is excluded from being optm’ed

    Best regards,

    Thread Starter popaionut

    (@popaionut)

    Hello QTWRK,

    I’m adding the critical css as so:

     echo '<style data-no-optimize="1">';
     include_once(get_template_directory() . '/assets/css/critical/main-critical.min.css');
     echo '</style>';
    

    This is hooked with an action I’ve made in the theme in header.php, just below the charset line. In Source it shows up correctly as <style data-no-optimize=”1″>…</style>, but once the combine action is checked these styles disappear (they’re 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.

    • This reply was modified 4 months, 3 weeks ago by popaionut.
    • This reply was modified 4 months, 3 weeks ago by popaionut.
    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    okay , I see , you are making it inline CSS

    data-no-optimize="1" works on CSS file for sure , but it seems didn’t 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,

    Thread Starter popaionut

    (@popaionut)

    Partials seem to work just fine. Thanks for the tip.

    • This reply was modified 4 months, 3 weeks ago by popaionut.
    Plugin Support Hai Zheng⚡

    (@hailite)

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.