Lazy-loading short product videos inside a CMS Load list?

Has anyone found a clean way to lazy-load short product videos inside a CMS Load list (Attributes v2)?

The setup I have in mind: each CMS item has a 10–20 second MP4 (for example clips exported from an AI video tool such as Nereo), and the collection is paginated with “load more”.

Two things I’m unsure about:

  1. Is preload="none" plus a poster image enough on mobile, or is it better to only set the src when an item scrolls into view?
  2. When CMS Load appends the next batch, does an IntersectionObserver set up on the first page pick up the new items automatically, or does it need to be re-initialised after each load (e.g. via the fs-cmsload callbacks)?

Any pointers or examples would be appreciated.

Hey @ryan.whitaker321!

Both of your approaches are valid, but they solve slightly different problems — here’s how to think about them.

preload="none" + poster tells the browser to skip fetching video data until the user interacts or you call .play(). It’s a solid baseline, especially on mobile where browsers are already conservative. IntersectionObserver with a data-src swap is stricter — with preload="none" alone, browsers may still establish connections or fetch metadata as items enter the viewport. Keeping the URL in data-src and only moving it to src on viewport entry guarantees zero network activity until that moment.

For a paginated list with lots of short clips, combining both gives you the tightest control.

On your second question — you’re right to flag this. An IntersectionObserver does NOT automatically pick up newly appended items from CMS Load. It only watches elements you explicitly pass to observer.observe(). New <video> elements added by “load more” won’t be tracked.

The cleanest fix is hooking into the Attributes v2 JavaScript callback API:

window.FinsweetAttributes ||= [];
window.FinsweetAttributes.push(['list', async (listInstances) => {
  const [listInstance] = listInstances;

  const videoObserver = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        const video = entry.target;
        const src = video.dataset.src;
        if (src && !video.src) {
          video.src = src;
          video.load();
        }
        videoObserver.unobserve(video);
      }
    });
  }, { rootMargin: '200px' });

  function observeVideosInItems(items) {
    items.forEach(item => {
      const video = item.element.querySelector('video[data-src]');
      if (video) videoObserver.observe(video);
    });
  }

  observeVideosInItems(listInstance.items);

  listInstance.addHook('afterRender', (renderedItems) => {
    observeVideosInItems(renderedItems);
  });
}]);

A few things worth noting here — window.FinsweetAttributes.push(['list', callback]) is the v2 API (v1 used window.fsAttributes and 'cmsload'). The afterRender hook fires each time new items hit the DOM, whether from pagination, load more, or initial render. And renderedItems gives you just the new batch, so you’re only observing what’s freshly added.

Your video markup should look like this — note the src is intentionally omitted:

<video
  data-src="[your-cms-video-url]"
  poster="[your-cms-poster-url]"
  preload="none"
  playsinline
  muted
></video>

There’s also a MutationObserver approach if you’d rather not use the Finsweet callback API — it watches the Collection List for childList additions and is more framework-agnostic. That said, the afterRender hook is more direct when you’re already on Attributes v2.

Could you share a staging or read-only link to your project? :folded_hands: We’d like to see how you’re storing the video URLs in the CMS and make sure the hook integrates cleanly with your setup. :flexed_biceps: