AMP integration incompatible with pages using ESM scripts
-
AMP now supports serving modern ESM scripts to browsers.
So instead of:
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
You can instead serve:
<script async="" custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.mjs" type="module" crossorigin="anonymous"></script> <script async="" nomodule="" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" crossorigin="anonymous" custom-element="amp-analytics"></script>
When this is being done, all scripts need to be served with both
module
andnomodule
versions, or else a validation error occurs:There are scripts in the page using different release versions.
This validation error is currently being caused by Ezoic as seen in this AMP support topic.
What’s the status on being compatible with the AMP plugin as I posted 7 months ago?
All you need to do is output the
<amp-analytics>
tag at thewp_footer
action (oramp_post_template_footer
action for legacy Reader templates). Then the AMP plugin will automatically generate the required AMP scripts whether ESM is enabled or not.
- The topic ‘AMP integration incompatible with pages using ESM scripts’ is closed to new replies.