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!
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
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.
@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.