Urgent.News

What's breaking now, across thousands of outlets.

Tech

Stop YouTube embeds slowing your Shopify homepage: a click-to-load video section

Paste a YouTube iframe into a Shopify section and every visitor downloads YouTube's player before they've decided to watch anything. On a homepage, that's often the heaviest thing on the page, and most people never press play. The fix is old and simple: show a cover image and a play button, and only create the iframe when someone clicks. This post is a complete section you can drop into any…

YouTube iframe embeds on a Shopify homepage can significantly slow down page load times, as the player is downloaded before the viewer decides to watch any content. This issue is particularly prevalent on the homepage where the heavy player download often goes unnoticed by most users. To address this, a simple solution involves displaying a cover image and a play button, loading the actual iframe only when the user clicks on the button.

Shopify's Dawn theme already implements this approach using a Video section that wraps the iframe in a section inside a deferred-media element. If you are using this theme or a custom section built from it, you are likely fine. However, in cases where a raw iframe is pasted into a custom Liquid section or an older theme with its own video section, the following steps can be taken.

To implement the click-to-load video section, create a new section named `sections/video-on-click.liquid`. Within this section, assign the YouTube video URL and title from the section settings. Use conditional logic to check if a video URL is present and, if so, create a button with the specified label and attach the necessary data attributes.

Apply CSS styles to the section, positioning the video area relative to the parent container and setting the aspect ratio to 16:9. Create a poster image using the cover image provided by the merchant or a default YouTube thumbnail if no cover image is available. Add a play button using the `video-on-click__play` class, positioning it absolutely within the poster image.

Include JavaScript code to listen for click events on the poster image. When the button is clicked, create an iframe element, set its source based on the video type (YouTube or Vimeo), and replace the button with the iframe element. This ensures that the iframe only loads after the user interacts with the section.

Finally, define the section settings and presets in the schema block. The `video_url` setting parses the YouTube or Vimeo link, providing the necessary video ID and type information. Include fields for the video URL, cover image, and button label, along with default values for convenience.

By following these steps, you can effectively implement a click-to-load video section on your Shopify homepage, improving load times and providing a better user experience for your visitors.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at dev.to →

More in Tech

Frame-perfect gameplay videos from Godot 4 without a screen recorder

We make small mobile puzzle games in Godot, and we need a steady supply of vertical gameplay clips for YouTube Shorts and TikTok.

  • Godot 4 developers developed method to create gameplay videos without screen recorders.
  • Camera placed inside engine to render frames to offscreen viewport and save to disk.

SSH Compression After OpenSSH 10.6: What Changed (2026)

If you have Compression yes in your ~/.ssh/config or type ssh -C out of habit, your transfers may have quietly grown. OpenSSH 10.6, released on October 6, 2026, disabled the LZ77 part of SSH…

  • OpenSSH 10.6 reduces SSH compression effectiveness
  • LZ77 dictionary coder disabled in zlib compression
  • Change aims to mitigate side-channel leaks

How to Make a Karaoke Track from Any Song

Friday night, living room, and the only thing missing is the version of the song without the singer in it. Making a karaoke track used to mean hunting for an official instrumental that usually doesn't…

  • Split song in browser using audio file or video extraction
  • Choose AI vocal removal engine that runs locally
  • Perform finishing touches before sharing karaoke track

More from Friday 13 November →