-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transformer: Strip comments #13
Comments
Previously: ampproject/amp-wp#2842. |
Fixed via #251 |
Hello, I need HTML comments to be present in my AMP page. I don't understand if is this feature that is removing them, how can I verify? |
@DrLightman Yes, the MinifyHTML transformer strips out the comments by default.
Are you using AMP WP plugin? |
Hi @ediamin Yes the official plugin from here https://wordpress.org/plugins/amp/ ( Ok so I mighy hack in the code you kindly provided by setting that to |
You can use the amp_optimizer_config filter. You can try this snippet, use AmpProject\Optimizer\Configuration\MinifyHtmlConfiguration;
use AmpProject\Optimizer\Transformer\MinifyHtml;
function minifyhtml_disable_remove_comments( $config ) {
$config[ MinifyHtml::class ] = [
MinifyHtmlConfiguration::REMOVE_COMMENTS => false,
];
return $config;
}
add_filter( 'amp_optimizer_config', 'minifyhtml_disable_remove_comments' ); |
Thank you very much @ediamin ! |
Feature description
Add logic to the existing
Minify
transformer so that it strips unneeded comments.A configuration will be needed to let users add to that patterns of comments to skip.
Related ampproject/amp-wp#4213
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: