• Resolved ajsmorillas

    (@ajsmorillas)


    Hi, some issues with AMP, ?any idea?

    AMP does not allow the use of JS <script> tags unless they are for loading AMP components, which are added automatically by the AMP plugin. For any page to be served as AMP, all invalid script tags must be removed from the page. Instead of custom or third-party JS, please consider using AMP components and functionality such as amp-bind and actions and events (as opposed to JS event handler attributes like onclick). Some custom JS can be added if encapsulated in the amp-script. Learn more about how AMP works.
    
    If all invalid markup is “removed” the page will be served as AMP. However, the impact that the removal has on the page must be assessed to determine if the result is acceptable. If any invalid markup is “kept” then the page will not be served as AMP.

    Error code DISALLOWED_TAG
    Invalid markup <script>
    Element name script

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Thanks for the message.

    Yeah, sadly it may not work very well with AMP sites, however I’ll certainly take a look into it at some point.

    As far I’ve not used amp pages for some long time ago, I don’t know if the spec’s for amp pages was changed, but if not, no other js scripts other than the amp uses are allowed aka no user js are allowed at all.
    So you need to check if the request is made to an amp endpoint.
    There was a wp function to do that in the oficial amp plugin: is_amp_endpoint() but that was obsoleted and changed to amp_is_request() in the 2.0 version.
    So unless the spec’s for user js was changed you need some like
    if (amp_is_request()) return;
    At some point in the plugin code (Maybe in some of the first lines of code?)
    That is valid ONLY for the oficial amp plugin, some others amp plugins need to use others functioms.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘AMP compatibility?’ is closed to new replies.