
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
youtube-lazyload
Advanced tools
Install this package and lazy load all the youtube video with the class "youtube". Ideal for loading the site quickly.
npm install youtube-lazyload
On HTML use following code:
<div class="wrapper">
<div class="youtube" data-embed="EQW3n5aGdSI">
<div class="play-button"></div>
</div>
</div>
Note:
Value of the data-embed is the id of the youtube video. For e.g.
if the youtube link is: https://www.youtube.com/embed/EQW3n5aGdSI
then, the data-embed is : EQW3n5aGdSI
To allow fullscreen, add attribute data-fullscreen="true". For e.g.
<div class="wrapper">
<div class="youtube" data-embed="EQW3n5aGdSI" data-fullscreen="true">
<div class="play-button"></div>
</div>
</div>
To disable fullscreen, either remove attribute "data-fullscreen" or set it to false data-fullscreen="false"
Use the following style:
.wrapper {
max-width: 680px;
margin: 60px auto;
padding: 0 20px;
}
.youtube {
background-color: #000;
margin-bottom: 30px;
position: relative;
padding-top: 56.25%;
overflow: hidden;
cursor: pointer;
}
.youtube img {
width: 100%;
top: -16.82%;
left: 0;
opacity: 0.96;
}
.youtube .play-button {
width: 90px;
height: 60px;
background-color: #333;
box-shadow: 0 0 30px rgba( 0,0,0,0.6 );
z-index: 1;
opacity: 0.8;
border-radius: 6px;
}
.youtube .play-button:before {
content: "";
border-style: solid;
border-width: 15px 0 15px 26.0px;
border-color: transparent transparent transparent #fff;
}
.youtube img,
.youtube .play-button {
cursor: pointer;
}
.youtube img,
.youtube iframe,
.youtube .play-button,
.youtube .play-button:before {
position: absolute;
}
.youtube .play-button,
.youtube .play-button:before {
top: 50%;
left: 50%;
transform: translate3d( -50%, -50%, 0 );
}
.youtube iframe {
height: 100%;
width: 100%;
top: 0;
left: 0;
}
This is the exact copy of the code by https://codepen.io/tutsplus/. The working example is available on the Codepen.
FAQs
Lazy load youtube video
We found that youtube-lazyload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.