Site logo

[Resolved] Turn off Secondary Menu on Mobile without relying on css

Home Forums Support [Resolved] Turn off Secondary Menu on Mobile without relying on css

Home Forums Support Turn off Secondary Menu on Mobile without relying on css

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #1538100
    David

    I explained this at the beginning of this post. By bloating a page with html and then hiding with css is cloaking and slows down rendering. Google is getting better at detecting this.

    When I hide the secondary nav with css:

    On desktop Google PageSpeed Insights drops my score from 100 to 93 for a Cumulative Layout Shift (CLS) greater than 1. While the mobile version still scores 100.

    Because of this WordPress has made a function wp_is_mobile so that you do not have to include all the extra html that you are going to hide with css (cloaking). And caching plugins like WP Rocket enable two versions of your website to be served.

    https://docs.wp-rocket.me/article/708-mobile-caching

    #1538265
    Tom
    Lead Developer
    Lead Developer

    If that code works while you were logged in, it should work when you’re logged out as long as the cached has been cleared after the code has been added.

    Have you tried clearing the cache once the function is active?

    #1538272
    Leo
    Staff
    Customer Support

    Just saw a not from David and he mentioned that “if the server has page caching and there is no separate mobile cache (not all server configs do) then there’ss a risk that the HTML from desktop gets cached and that too gets displayed on mobile devices.”

    Sounds like this could be the issue as well.

    #1538275
    David

    Yes, I have decided against a secondary nav. I want to keep my 100 page speed score on Desktop and Mobile and this is not possible with a secondary nav at the moment. Thank you.

    #1538284
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 5 posts - 16 through 20 (of 20 total)
  • The topic ‘Turn off Secondary Menu on Mobile without relying on css’ is closed to new replies.