Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bjrnet21

    (@bjrnet21)

    I have 4 Youtube videos on this page. Only one (the first one) caused the “Defer parsing of JavaScript” hit due to the base.js call.

    When I move that video to the bottom of the page the page loads incredibly faster and I don’t get the GTMetrix hit.

    Thread Starter bjrnet21

    (@bjrnet21)

    Looks like if a Youtube video is near the top – visible on first load of page – it gets loaded.

    For those pages, I now use an alternate loading method which works great. I found it at https://www.labnol.org/internet/light-youtube-embeds/27941/ .

    You need to take a snapshot of the YouTube video page and make an image. Then use code like:
    <div class=”youtube-player” style=”margin-left: auto; margin-right: auto;” data-id=”xxxxxxxxxxxx”>xxxxxxxxxxx</div>

    Some script + styles also has to be added to the page.

    Example: https://www.blackjackreview.com/wp/encyclopedia/xyz/

    You will notice that the first video on the page uses the labnol.org technique and the next video uses the lazy load technique. It gets a A(97%) + A(96%) on GTmetrix and loads in 1.8 seconds. Before the labnol.org technique was added it got grades of B’s and an F for the “Defer parsing of JavaScript”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Youtube – Defer parsing of JavaScript’ is closed to new replies.