1.1 KiB
1.1 KiB
lazyYT.js
Description
This is a jQuery plugin to lazy load Youtube videos. On the initial load, the div will be replaced by a preview img of the video. On click of the image, the preview img will be replaced by the autoplaying iframe Youtube video.
Intro
To read more information on the plugin and access a demo, view the intro post on newmediacampaigns.com.
Demo
Setup
<div class="lazyYT" data-youtube-id="_oEA18Y8gM0" data-width="300" data-height="200">loading...</div>
- Include the lazyYT JS and CSS files.
- Add a
divwhere you want the video to be located. Add the id of the Youtube video to the data attributeyoutube-id. - Add the video width to
data-width. A percentage is fine for fluid videos. - Add the video height to
data-height. - Any optional parameters you wanted passed to the iframe url should be added to
data-parameters. - Get it started with
$('.lazyYT').lazyYT();
License
MIT