Support » Plugin: AMP » Disable tree shaking on custom CSS

  • Resolved James I.

    (@nootropixcom)


    Hi,

    How do I disable tree shaking on my custom css added via amp_post_template_css? (I’m using reader theme).

    Thanks,

    Giacomo

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @nootropixcom

    Thank you for contacting us, Can you please help us understand why you want to disable tree shaking on custom CSS added via amp_post_template_css

    Additionally please send us the sample CSS code that you are trying to keep on AMP pages.

    We hope this helps!

    Thread Starter James I.

    (@nootropixcom)

    Hi,

    The problem is that a lot of CSS is removed even though CSS usage is only 22%.

    In the past there was the option to disable “optimize css” from what I understand, how can I do it now?

    Thanks,

    Giacomo

    Plugin Author Weston Ruter

    (@westonruter)

    What CSS specifically is being removed that should remain?

    In any case, you can disable tree shaking with the following plugin code:

    <?php
    add_filter( 'amp_content_sanitizers', static function ( $sanitizers ) {
        $sanitizers[ AMP_Style_Sanitizer::class ]['skip_tree_shaking'] = true;
        return $sanitizers;
    } );

    But ideally the tree shaker would just not be removing the CSS that is still being used on the page.

    Plugin Support Milind More

    (@milindmore22)

    @nootropixcom As we didn’t receive a response I’ll mark this as resolved. Feel free to open a new support topic if you require any further assistance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable tree shaking on custom CSS’ is closed to new replies.