According to the official “AMP HTML Specification“,
But when adding
<noscript>tags using the block editor Custom HTML block, they are being commented out on AMP pages, this way:
Is it something that supposed to be fixed?
- This topic was modified 1 year, 3 months ago by asafm7.
AMP_Script_Santitizerensures the content is visible while the <!–/noscript–> comment is an indicator.
Let us know if you have any further questions on this.
Thanks for your reply.
I’m not sure I fully understand though.
According to the documentation,
Again from the documentation:
The emphasis is mine.
Am I right?
- This reply was modified 1 year, 2 months ago by asafm7.
Are you looking to use
On a general note, I feel like the AMP plugin behavior should conform with the AMP documentation, isn’t it?
Anyway, yes, it will be great if you let me know if there are plans to change the behavior.
The AMP specification allows for
noscript, yes, but in general the most helpful behavior for existing plugins which aren’t built to support AMP is to unwrap the
noscriptelements so that their contents become the fallback on the AMP page. We don’t currently have a way to prevent this unwrapping behavior, but we could introduce it via some class name like
But are you embedding the Gists via the
amp-gistcomponent? If so, the best fallback approach would be to put the text content inside of the
amp-gistcomponent as a
fallbackchild. Like so:
<amp-gist data-gistid="e5032d805625f0f743237708c43d3783" layout="fixed-height" height="400"> <pre fallback> <?php /** * AMP Mobile Server-Side Redirection plugin bootstrap. * * @package Google\AMP_Mobile_Server_Side_Redirection * @author Weston Ruter, Google * @license GPL-2.0-or-later * @copyright 2021 Google Inc. * * @wordpress-plugin * Plugin Name: AMP Mobile Server-Side Redirection * Plugin URI: https://gist.github.com/westonruter/e5032d805625f0f743237708c43d3783 * Description: Disable the default client-side JS-based mobile redirection in lieu of opt-in in to server-side HTTP redirects. The AMP plugin does client-side redirection by default since it is most compatible across various caching plugins, but if possible you should use server-side redirection because it is always faster. * Version: 0.1 * Author: Weston Ruter, Google * Author URI: https://weston.ruter.net/ * License: GNU General Public License v2 (or later) * License URI: http://www.gnu.org/licenses/gpl-2.0.html * Gist Plugin URI: https://gist.github.com/westonruter/e5032d805625f0f743237708c43d3783 */ add_filter( 'amp_mobile_client_side_redirection', '__return_false' ); </pre> </amp-gist>
I’m not directly using
<amp-gist>, but rather Jetpack’s Shortcode Embeds functionality which does everything automatically with the block editor (including fetching
<amp-gist>on AMP pages, and regular markup on regular pages), and that’s why embedding the code is not really an option.
As you guessed, I prefer gists over the native code block because of syntax highlighting.
I tend to choose official solutions over solo-developer plugins, because of a better chance of future-proofness. If a native syntax highlighting code block would be merged to the WordPress core – it will be great.
Following this, do you think there is any chance for a change in
noscriptbehavior? (or, even better, for your plugin to be merged to core? :))
@westonruter btw I just tried your plugin and it’s great!
It turns out there is a way to prevent
noscriptfrom being unwrapped at present. All you have to do is add a
data-ampdevmodeattribute to the
noscript. For example:
<noscript data-ampdevmode> <p>Sorry, you have JS turned off!</p> </noscript>
This is not super intuitive, but it basically means that AMP conversions should be skipped for the element. I’ve opened an issue to improve on that: https://github.com/ampproject/amp-wp/issues/6030
Nevertheless, you can use that technique for now.
- The topic ‘Support’ is closed to new replies.