RichRBX
RichRBX

Reputation: 25

Can I defer an image on mobile only but not on desktop?

I have an image that loads in my header on mobile. This is a full width image that sits at the top of the page, meaning I cannot defer it as it contributes to the LCP on desktop.

However, on mobile this image has a "display:none" class as it isn't needed to help speed up mobile page load. I am getting the Google Pagespeed warning on mobile to defer this image.

Is there a way to correctly not load this image at all on mobile devices, a better route than to display:none? Or is there a way to defer the image on mobile only so it doesn't affect the LCP score for desktop?

Current code is

<img class="full-width-scroller-bg-image desktop-only" src="<?php echo $thumb;?>" width="1920px" height="1080px" alt="Image alt tag"/>

Thanks

Upvotes: 0

Views: 102

Answers (0)

Related Questions