Load youtube video using datasrc instead of iframe

To load a YouTube video using data-src instead of an iframe, you can lazy load the video to improve performance, especially when dealing with multiple videos on a page. Here’s how you can do it:

HTML Structure
You can create a div with a data-src attribute that holds the YouTube video URL. Initially, the video iframe will be replaced with an image (thumbnail) or a placeholder. When the user interacts with the element (e.g., clicks on it), the actual iframe is loaded.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *