Site speed: defer loading until scroll event

Highlighted
New Member
3 0 0

I'm currently using a number of third party apps on my site including tideo and hotjar and as a result my time to become interactive on site has become very slow, I'm following this tutorial and I'm wondering what part of the theme template will I be able to load the following code into to make sure a few of my apps load after a scroll event?

 

window.addEventListener('scroll',() =>
    setTimeout(() => {
      // load Tideo here etc ...
    }, 1000),
  { once: true }
);

Thank you very much,

0 Likes
Highlighted
New Member
3 0 0

Anyone that can help with this? Thanks

0 Likes
Highlighted
Excursionist
25 2 4

Use LazyLoad, recommand by shopify. Many themes already implemented Lazyload.

 

https://www.shopify.com/partners/blog/lazy-loading

0 Likes