1

I need to preload some images off-screen while page is loading and also - in a seperate case - serve smaller versions (ie cropped) of the same images to mobile.

What is the best way of doing this, preferably without a plugin?

2 Answers 2

1

You can add lazy loading to your image tags...

<img src="/path/to/image" width="640" height="480" alt="My image" loading="lazy">
3
  • Is that native EE? Commented Jul 15 at 18:16
  • 1
    It's a standard HTML attribute for the IMG tag. Commented Jul 17 at 0:03
  • Agreed + the src-set attribute to serve smaller images for devices Commented Jul 29 at 8:51
0

You can use the native image manipulations to generate cropped images for mobile. Than you can use css to display the smaller ones to small screens. But it might be cleaner to use Mo Variables (free addon) to detect if a mobile device visits the page and only load the correct image {if is_phone}load small image{/if} {if is_desktop}load large image{/if}

Same goes for preloading i guess

3
  • thanks for this. Very helpful. I can't find Mo Variables though... I used to have it on Devotee I think but that site is dead now... You know where I can find it? Is not on EE Addons either Commented Jul 15 at 10:54
  • 1
    here it is: github.com/rsanchez/mo_variables Commented Jul 15 at 11:17
  • Native HTML can do this now with srcset so there's no need for an addon. Then all you need is a EE image manip for each breakpoint Commented Jul 29 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.