gajus/youtube-player

Stop loading uselessly YouTube iframe_api

Open

#72 创建于 2018年9月19日

在 GitHub 查看
 (1 评论) (0 反应) (1 负责人)JavaScript (80 fork)github user discovery
enhancementhelp wanted

仓库指标

Star
 (386 star)
PR 合并指标
 (PR 指标待抓取)

描述

Hi everyone,

I would like to point out that src/loadYouTubeIframeApi.js loads the iframe_api script unnecessarily even though window.YT is already defined.

In line 15, there is a check if (window.YT && window.YT.Player && window.YT.Player instanceof Function)...

and the line 36 which loads the script load(protocol + '//www.youtube.com/iframe_api', (error) => {...

isn't in a else statement attached to the condition of line 15, and it must be in my opinion because it will prevent making a request to YouTube which is exactly what i would like because not only i have all the needed scripts being previously loaded and already exposing window.YT, but the app that i'm building lives behind a proxy restraining all external requests

I could submit a PR for that. What do you think ?

Best regards

贡献者指南