• Hi,
    I am working on a website which is full AMP. So all the pages and posts are AMP enabled. I am using the official AMP plugin for this. Everything works fine but there is one invalid script tag generated by W3TC. I did install the AMP extension but this does not seem to be usable in my situation, since I am not a amp using tag nor a query sting.

    This issue seems similar to this topic, but it seems the problem wasn’t fixed.

    The invalid script tag is caused by this function “w3tc_popupadmin_bar”. See full log below:

    Informatie
    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 attributes
    type	text/javascript
    Element name
    script
    Parent element
    head
    Text content
    			function w3tc_popupadmin_bar(url) {
    				return window.open(url, __SINGLE_QUOTED_STRING__, __SINGLE_QUOTED_STRING__);
    			}
    		
    Sources
    #1	Type:	 Core
    Naam:	wp-includes
    Functie:	wp_print_head_scripts()
    Actie:	wp_head (priority 9)
    Locatie:	script-loader.php:2031
    #2	Type:	 Plugin
    Naam:	W3 Total Cache (w3-total-cache)
    Functie:	W3TC\Generic_Plugin::popup_script()
    Actie:	wp_print_scripts (priority 10)
    Locatie:	Generic_Plugin.php:648

    Thanks in advance!!

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jdrboost

    I am sorry about the issue you are experiencing and I am happy to help!
    Can you please confirm that you are using this AMP plugin?
    Also, how did you perform the AMP validation and are you using any Specific AMP settings?
    Thanks!

    Thread Starter Justin de Ruiter

    (@jdrboost)

    Hi Marko,

    Thank you for your response.

    I am indeed using the plugin you linked. This plugin has a built in check to determine if pages are AMP proof (see screenshot). If not the plugin will remove the incompatible code. In this case the script tag. This is a screenshot of the full error message it shows, which I also posted in the previous post.

    I am using the standard theme mode of the AMP plugin and i am not using any custom settings.

    btw: it seems that the plugin (and AMP) still works fine after the script tag is removed by AMP, so this is not a huge disaster. However AMP display’s a warning in the wordpress dashboard and Search Console. I prefer to get rid of the warning since this is a client website.

    Let me know if you need any more info and thanks again!

    Kind regards,
    Justin

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jdrboost

    Thank you for the information.
    Just to confirm, this does not affect the functionality of the AMP pages and the website?
    I’ll investigate this more and get back to you as soon as I have more info about this.
    Thanks!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jdrboost

    Thank you for your patience.
    THe script:

    <script type="text/javascript">
                function w3tc_popupadmin_bar(url) {
                    return window.open(url, '', 'width=800,height=600,status=no,toolbar=no,menubar=no,scrollbars=yes');
                }
            </script>

    is added by:
    add_action( 'wp_print_scripts', array( $this, 'popup_script' ) );

    Loads if the function exists:
    wp-includes/admin-bar.php:function is_admin_bar_showing() {
    So that loads only when the user is logged in in the dashboard. This means that this is not preventing any AMP functionality.

    Thanks!

    Thread Starter Justin de Ruiter

    (@jdrboost)

    Hi Marko,

    Thanks for figuring this out for me!

    Kind regards,

    Justin

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jdrboost

    You are most welcome!

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘W3TC not valid for AMP’ is closed to new replies.