Is your website load slower whenever you embedded YouTube video on it
So how to solve this for your website and make load faster than ever before
Just simple steps to follow
1 Get the embed code
<iframe width=”560″ height=”315″ src=”https://www.youtube.com/watch?v=_VWyQqZwHCY” frameborder=”0″ allowfullscreen></iframe>
2 Change Code Like Below
<iframe width=”560″ height=”315″ src=”” data-src=”//www.youtube.com/embed/_VWyQqZwHCY” frameborder=”0″ allowfullscreen></iframe>
3. Add Below Java script to bottom of page
<script>
function init() {
var vidDefer = document.getElementsByTagName(‘iframe’);
for (var i=0; i<vidDefer.length; i++) {
if(vidDefer[i].getAttribute(‘data-src’)) {
vidDefer[i].setAttribute(‘src’,vidDefer[i].getAttribute(‘data-src’));
} } }
window.onload = init;
</script>
before the end body tag in your website
Example video
Find More about this in–depth Post here – Deferring videos
Amit Surti
Latest posts by Amit Surti (see all)
- SEO Link Building {That Works} - Dec 4, 2019
- OptinMonster Review: Lead Generation Plugin For All - Dec 2, 2019
- Hostgator Coupon Code: 100% Valid HostGator 1 Cent Hosting Coupon – December 2019 - Dec 2, 2019