In addition to content, loading speed of posts is 'everything' for a blog owner. Anything will be done to improve page loading speed, and all things that can slow down loading will be eliminated or solutions must be sought to reduce harm.
With the increasing mobility of people around the world, more and more users are accessing web pages using mobile phones, and when high-speed wireless networks are still not available in many cities, light and fast loading of pages are still very important.
To see the effect of an embedded iframe Youtube video in a post to load speed, you may do a test with GTmetrix. First check the speed before installing a Youtube video in a post, and then check the speed and the GTmetrix scores after Youtube video is installed in the post.
How to do a defer parsing Youtube video to speed up loading in Blogger in this post is using a script for WordPress that I found somewhere and modified it by adding a 'container', so it can be used in Blogger or Blogspot.
To do a defer parsing Youtube video in Blogger, please follow the steps below, and before making any changes do not forget to make backup, as a precaution in case of there's a mistake during the process:
- Login to Blogger --> Theme --> Edit HTML.
- Place followng script before </body>
<script type='text/javascript'>
//<![CDATA[
function init() {
var DeferParse = document.getElementsByTagName('iframe');
for (var i = 0; i < DeferParse.length; i++) { if (DeferParse[i].getAttribute('data-src')) { DeferParse[i].setAttribute('src', DeferParse[i].getAttribute('data-src')); } } } window.onload = init; //]]> </script> - Save.
- Next is to copy paste embed iframe Youtube video into a post, which is usually like this :
<iframe width="560" height="315" src="https://www.youtube.com/embed/2oULsdRPVuw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
and add 'data-' before src, to make it like this :
<iframe width="560" height="315" data-src="https://www.youtube.com/embed/2oULsdRPVuw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Next, check again the loading speed of the post in GTmetrix. If everything goes well, then there will be a very significant increase in loading speed when compared to the score before installing the defer parsing Youtube video script. Please read also the posts Embedded Iframe Youtube Video Responsive 100% Width.
Label: Blog, Defer Parsing, Youtube
Bagikan ke: WhatsApp, Email. Print!.