Lite YouTube Embeds – A Better Method for Embedding YouTube Videos on your Website

Learn how to embed YouTube videos on your website in a fast, lightweight manner that loads the embedded video on demand thus reducing the size of your web pages and improving your core web vitals score.

Published in: EmbedYouTube

It is easy to embed a YouTube video but you’ll be surprised to know how much extra weight a single YouTube video embed can add to your web pages. The browser has to download ~800 kB of data (see screenshot) for rendering the YouTube video player alone. And these files are downloaded even before the visitor has clicked the play button.

The embedded YouTube video not only increases the byte size of your web pages but the browser has to make multiple HTTP requests to render the video player. This increases the overall loading time of your page thus affecting the page speed and the core vitals score of your website.

The other drawback with the default YouTube embed code is that it renders a video player of fixed dimensions and isn’t responsive. If people view your website on a mobile phone, the video player may not resize properly for the small screen.

Embed YouTube Videos without Increasing Page Size

The now defunct Google+ employed a very clever technique for embedding YouTube videos. When the page was initially loaded, Google+ would only embed the thumbnail image of the YouTube video and the actual video player was loaded only when the user clicked inside thumbnail.

The thumbnail frame image of YouTube videos are about 15 kB in size so we are able to reduce the size of web pages by almost an MB.

Lite YouTube Embed Demo

Open this demo page to view the Google+ technique in action. The first video the page is embedded using the default IFRAME code while the second video uses the lite mode that loads the YouTube video on demand only.

When a user clicks the play button, the thumbnail image is replaced with the standard YouTube video player with autoplay set to 1 so the video would play almost instantly. The big advantage is that the extra YouTube JavaScript gets loaded only when someone decides to watch the embedded video and not otherwise.

Light and Responsive YouTube Embeds

The standard embed code for YouTube uses the IFRAME tag where the width and height of the video player are fixed thus making the player non-responsive.

The new on-demand embed code for YouTube is responsive that adjusts the player dimensions automatically based on the screen size of the visitor.

YouTube Embed Code

Embed YouTube Videos Responsively – Tutorial

Step 1: Copy-paste the following HTML snippet anywhere in your web page where you would like the YouTube video to appear. Remember to replace VIDEO_ID with the actual ID of your YouTube video.

<div class="youtube-player" data-id="VIDEO_ID"></div>

We will not assign height and width since the video player will automatically occupy the width of the parent while the height is auto-calculated. You can also paste multiple DIV blocks with different video IDs if you need to embed multiple YouTube videos on the same page.

Step 2: Copy-paste the JavaScript anywhere in your web template. The script finds all embedded videos on a web page and then replaces the DIV elements with the video thumbnails and a play button (see demo).


  function labnolIframe(div) {
    var iframe = document.createElement('iframe');
      '' + + '?autoplay=1&rel=0'
    iframe.setAttribute('frameborder', '0');
    iframe.setAttribute('allowfullscreen', '1');
      'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
    div.parentNode.replaceChild(iframe, div);

  function initYouTubeVideos() {
    var playerElements = document.getElementsByClassName('youtube-player');
    for (var n = 0; n < playerElements.length; n++) {
      var videoId = playerElements[n];
      var div = document.createElement('div');
      div.setAttribute('data-id', videoId);
      var thumbNode = document.createElement('img');
      thumbNode.src = '//'.replace(
      var playButton = document.createElement('div');
      playButton.setAttribute('class', 'play');
      div.onclick = function () {

  document.addEventListener('DOMContentLoaded', initYouTubeVideos);

Step 3: Copy-paste the CSS before the closing head tag of your web template.

  .youtube-player {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    background: #000;
    margin: 5px;

  .youtube-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: transparent;

  .youtube-player img {
    object-fit: cover;
    display: block;
    left: 0;
    bottom: 0;
    margin: auto;
    max-width: 100%;
    width: 100%;
    position: absolute;
    right: 0;
    top: 0;
    border: none;
    height: auto;
    cursor: pointer;
    -webkit-transition: 0.4s all;
    -moz-transition: 0.4s all;
    transition: 0.4s all;

  .youtube-player img:hover {
    -webkit-filter: brightness(75%);

  .youtube-player .play {
    height: 72px;
    width: 72px;
    left: 50%;
    top: 50%;
    margin-left: -36px;
    margin-top: -36px;
    position: absolute;
    background: url('//') no-repeat;
    cursor: pointer;

You can view the light YouTube embed technique in action on this Codepen page.

Please do note that Chrome and Safari browsers on iPhone and Android only allow playback of HTML5 video when initiated by a user interaction. They block embedded media from automatic playback to prevent unsolicited downloads over cellular networks.

YouTube Embed Tutorials

  1. Embed a YouTube Video with Sound Muted
  2. Place YouTube Video as your Webpage Background
  3. Embed Just a Portion of a YouTube Video

Source link

Embedding literacy coaches ‘absolute gold’ for one Tasmanian primary school

A primary school in Hobart’s northern suburbs has dramatically improved its students’ literacy by blending innovative ways of teaching with tried and true methods.

In 2016, senior staff at Rosetta Primary realised some students’ results were not improving as they should.

It sparked the curiosity of advanced skills teacher Deb Button — and her research and dedication have since led to a whole-of-school approach to teaching reading and spelling, including a method known as Multisensory Structured Language.

“It’s direct, explicit, it’s sequential, we constantly review what we do, and it also means they see it, they hear it and they feel it,” Ms Button said.

“When I say feel, I mean how it feels in your mouth when you say a word … and that improves what they hear, what they see, and how it comes out on paper.”

Part of its benefit was that it was more tangible to learners, Ms Button said.

Literacy coach and support teacher Deb Button says aspiration is key to improving literacy outcomes.(ABC News: Luke Bowden)

“There’s not the — dare I say it — look, cover, write, check. ‘Here’s a worksheet, let’s have a test, we’ll do another test at the end of the week,'” she said.

“The reading and the spelling are so closely linked at the same time, so that means we hear it, we see it, we spell it … then we read it again.”

The model is promoted by the Australian Dyslexia Association, which notes the theory allows specially trained teachers to “adjust their teaching to meet the needs of the learners rather than expecting the learners to fit one way”.

Principal Deirdre Arendt said the results since implementing Multisensory Structured Language for students in grades one to three had blown her away.

“We’ve got students achieving across the board,” she said.

“Wherever they were at the beginning when they took this first assessment to the end of the year, it’s been well over a years’ growth of learning.

“That to us is absolute gold.”

Results a source of pride for Toby

A primary school boy smiles at the camera
Rosetta Primary School student Toby Shelton says he feels “very proud” about his progress.(ABC News: Luke Bowden)

Students appear to enjoy the new approach.

Toby Shelton, a seven-year-old in grade 1, said he struggled with “big, long words” but had learned to sound them out by “chopping” them into syllables.

“So you can say the first bit and the second bit and the third bit and the fourth bit. Then you can put it all together and say it in one big go,” he said.

“Long words kind of confuse me sometimes, but now I can see how it’s made up.”

Toby said it felt good to be able to read well compared to when he was “blind for words”. His favourite book is one on the Titanic, the Hindenburg and Boeing 747s.

Ms Button, just one of Rosetta Primary’s literacy coaches, said families were involved in their children’s learning too.

“I’ve had one parent say, ‘If only they’d done this when I was at school,'” she said.

“We’ve seen students who were not confident before who are willing to come and read, and the amount they’re reading has improved too … some of them are so hooked into reading, and we didn’t see that before.”

Annabel Graham is another grade 1 student benefiting from Rosetta Primary’s new approach.

She loves reading about dinosaurs and hopes to one day become a teacher.

“Because then I can teach students stuff that I’ve learned so there’ll be lots of smart people in the world,” she said.

Ms Button said aspiration was key: “By having that there, they all have a chance to succeed at a much higher level than they might’ve before.”

Improving literacy ‘a slow process’

A middle-aged woman sits in a classroom with two young students
Deb Button helps grade 3 students Sam Clifford (left) and Lasharne O’Brien with their literacy skills.(ABC News: Luke Bowden)

Tasmania’s public schools are allowed to choose their own methods of teaching in line with the Australian curriculum.

The state’s Education Department last year launched a Literacy Framework and Plan for Action, with the Government also pledging to allow all government schools access to literacy coaches.

Education Minister Jeremy Rockliff has set a target of 100 per cent functional literacy.

According to adult education service 26TEN, the existing figure among adults is about half that — in other words, 48 per cent of Tasmanians do not have the literacy and numeracy skills they need to live in a technologically driven society.

A review into the 26TEN service released this year said people with higher levels of literacy had a longer life expectancy.

“Accept that improving adult literacy is a slow process; with this in mind, the longer-term support and funding provided by the State Government is essential and represents persistence and sustainability,” the report said.

Ms Arendt, from Rosetta Primary, said paying for professional learning and the requisite relief teachers had not come cheap — but said it was more than worth it.

“If other schools are interested in doing a journey similar to ours, we’re more than happy to support and help in whatever ways we can,” she said.

Source link