• Resolved Avinash

    (@avii)


    Redirect mobile visitors to AMP option when enabled, first loads the mobile version of the theme and then switches to the AMP version. While opening pages on the mobile, the switching from Mobile to AMP version is visible. Any way the AMP version loads directly without loading the mobile version of the theme ??

    • This topic was modified 4 years, 2 months ago by Avinash.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Please share the URL to your site so we can observe the behavior you are describing.

    Plugin Author Weston Ruter

    (@westonruter)

    Note the default behavior is for redirection to the AMP version to happen as early as possible when mobile visitors access the non-AMP version. By default this redirection is performed in JavaScript, meaning it is expected for the non-AMP version to display briefly. However, the redirection logic happens in the head and should stop the page from loading before redirection happens.

    You can avoid the client-side redirection logic and use server-side redirection logic via PHP instead. You can do so by adding this PHP code to a custom plugin:

    add_filter( 'amp_mobile_client_side_redirection', '__return_false' );

    The reason why this is not the default is that client-side redirection is more reliable across the wide variety of WordPress hosting environments. If you have page caching (which you should), you’ll need to make sure that the cache is varied by mobile device in the same way as it is detected by the AMP plugin. For more, see §Client-side vs Server-side Redirection.

    Nevertheless, please still share the URL for your site because the non-AMP version should not be getting displayed prior to client-side redirection.

    Thread Starter Avinash

    (@avii)

    Thank you for the detailed response. Will try to test Client-side vs Server-side Redirection. At the moment, can’t share the URL as I have disabled the option for the moment as it’a live / production site.

    Regarding caching, yes the site uses Wp-rocket plugin and probably I need to tweak it a bit too on how it handles the javascript minification options etc w.r.t mobile. But probably later on some non-production site.

    Thank you again for the detailed response.

    Plugin Author Weston Ruter

    (@westonruter)

    Oh yes, if you’re using some minification logic then that could result in the head JS code being moved and resulting in the non-AMP page being displayed.

    If there’s some way to mark the script in WP Rocket as being exempted from minification, let me know, as that might make sense to include in the AMP plugin.

    Plugin Author Weston Ruter

    (@westonruter)

    I also noticed a bug with mobile redirection where AMP-to-AMP linking was not getting enabled. So this experience will be improved in v2.0.1.

    See https://github.com/ampproject/amp-wp/pull/5323

    Plugin Author Weston Ruter

    (@westonruter)

    Also, here’s the docs page on how to exclude inline scripts from combination in WP Rocket: https://docs.wp-rocket.me/article/1104-excluding-inline-js-from-combine

    Thread Starter Avinash

    (@avii)

    thanks a lot for the fabulous support here. will finetune wp rocket + wait for 2.0.1

    Plugin Author Weston Ruter

    (@westonruter)

    v2.0.1 is now published

    First of all, thank you for your amazing Work. Do you think that this kind of redirection can have some impact on SEO? Or maybe it’s better because of the always high speed on mobile? Best Regards

    Plugin Author Weston Ruter

    (@westonruter)

    The redirection approach is found in the Google Search documentation: https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls

    Thank you! ??

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Redirect mobile visitors to AMP option ??’ is closed to new replies.