How do you Defer Parsing of JavaScript for YouTube video on a WordPress site?

后端 未结 3 1422
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 18:46

I just today realized that of my 1.2 MB site (per GTMetrix), 550k of it is a YouTube video.

My web site is a WordPress site, and the current video loads in an iframe.

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 19:22

    1. Replace “scr” with “data-src”

    
    

    2. Add Javascript

    function init() {
    var vidDefer = document.getElementsByTagName('iframe');
    for (var i=0; i

    Now your site will load faster compared to past.

    I have following this blog and it's working for me : http://www.codecanal.com/defer-parsing-javascript-youtube-videos/

提交回复
热议问题