Site logo

[Resolved] Question about hide-on-mobile & page speed

Home Forums Support [Resolved] Question about hide-on-mobile & page speed

Home Forums Support Question about hide-on-mobile & page speed

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1805415
    Sasha

    Hello – 

    As I’m designing a responsive website, with lots of duplicate elements that are either “hide-on-deskstop” or “hide-on-mobile,” I am wondering – 
    Does this impact pagespeed? Do browsers load hidden content or ignore it?

    PS: I’d have fewer duplicate elements if more GP settings were customizable based on device. In particular, it would great to be able to adjust text alignment responsively!

    Thanks!

    #1805546
    Elvin
    Staff
    Customer Support

    Hi Sasha,

    Does this impact pagespeed? Do browsers load hidden content or ignore it?

    It can, especially if there are images.

    While some display: none;-ed image doesn’t show up on some viewports, the browser still loads them as they are still part of the DOM structure.

    This article explains it briefly – https://betterprogramming.pub/css-how-css-display-none-affects-images-on-page-load-dbdf1aaea820

    #1806750
    Sasha

    Thanks Elvin. What would you recommend as the most lightweight way to align text differently on mobile vs. desktop?

    i.e. a headline is centered on mobile but right-aligned on desktop

    #1806778
    Elvin
    Staff
    Customer Support

    Thanks Elvin. What would you recommend as the most lightweight way to align text differently on mobile vs. desktop?

    There’s no simpler way to do it but CSS and @media rule.

    Example:

    @media(min-width:769px){ /*desktop and tablets rule*/
    .your-headline-class-here {
    text-align: left;
    }
    }
    
    @media(max-width:768px){ /*mobile rule*/
    .your-headline-class-here {
    text-align: center;
    }
    }

    I’m not sure which element you’re pertaining to so I just added a .your-headline-class-here as an example. You can change the selector to the class of the headline you wish to target.

    #1806801
    Sasha

    This is helpful – thank you!

    #1806806
    Elvin
    Staff
    Customer Support

    No problem. 😀

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.