gajus/youtube-player

Stop loading uselessly YouTube iframe_api

Open

#72 opened on Sep 19, 2018

View on GitHub
 (1 comment) (0 reactions) (1 assignee)JavaScript (80 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (386 stars)
PR merge metrics
 (PR metrics pending)

Description

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

Contributor guide