Search code examples
optimizationlazy-loadingmodxmodx-revolution

Existing MODX lazy loading


I have a website and customer want to optimize it a bit so, is there any easy ways to make it through MODX plugin or snippet?

I tried to do it manually but it always take a lot of time.

Found no ways in internet. How can I achieve this?


Solution

  • I have been facing the same issue until I have found a way to implement lazy loading to all iframes and images by:

    1. Changing src to data-src for images and non-youtube iframes
    2. Changing YouTube iframe to img and getting video thumbnail directly from YouTube

    After that, I will initialize lazyload.js and execute some js.

    You can find full example and the code in the repository MODX-lazy-loader-snippet

    If you need any help, be free to comment on this answer and I will reply