Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, I wrote a javascript thingy (called "LYTE") that will create a "dummy player" (which looks &amp; feels like a normal YouTube embed) for every div with a specific class ("lyte") and id with the YouTube-id. Only when clicking the "dummy" player, the actual YouTube iframe is loaded and it indeed has an important impact of the performance of pages that embed YouTube videos. You can see it in action <a href="http://blog.futtta.be/category/tubeken" rel="noreferrer">on my blog</a>.</p> <p>LYTE is currently not really available standalone, only as part of <a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/" rel="noreferrer">WP-YouTube-Lyte, the WordPress plugin I wrote</a>, but with minimal changes you should be able to extract all relevant code from the plugin.</p> <p>You basically have to create something like this in your HTML;</p> <pre><code>&lt;div class="lyte" id="7nuiOe8M6bw" style="width:640px;height:385px;"&gt; &lt;script type="text/javascript"&gt;&lt;!-- var nT='newtube-';var bU='http://static.blog.futtta.be/wp-content/plugins/wp-youtube-lyte/lyte/'; var d=document;if(d.addEventListener){d.addEventListener('DOMContentLoaded', insert, false)}else{window.onload=insert} function insert(){if(!d.getElementById('lytescr')){lytescr=d.createElement('script');lytescr.async=true;lytescr.id='lytescr';lytescr.src='http://static.blog.futtta.be/wp-content/plugins/wp-youtube-lyte/lyte/lyte-min.js';h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(lytescr, h)}}; --&gt;&lt;/script&gt;&lt;/div&gt; </code></pre> <p>This block will load lyte-min.js, which will fill the div with all graphical elements of the dummy player (image, play button, control bar, title) and will add an eventlistener to the div that will trigger the replacement of the div with the real embedded player when clicked.</p> <p>You can find the plugin <a href="http://wordpress.org/extend/plugins/wp-youtube-lyte/" rel="noreferrer">here</a> and look at the code <a href="http://plugins.svn.wordpress.org/wp-youtube-lyte/tags/0.7.3/" rel="noreferrer">here</a> (wp-youtube-lyte.php creates the div, lyte/lyte.js is the actual javascript ... thingy). </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload